HI all!!
I have these struct:
typedef struct Edge {
int start;
int end;
} Edge;
typedef struct {
int dest;
int deg;
int nome;
Edge *edges;
} Vertex;
and in my main I have an initial structure Vertex* initial_partition, that contains all vertexes of a graph with all the field correctly filled.
Now I want to build a device structure that is exactly like this one, so I did:
Vertex* d_initial_partition;
cudaMalloc((void **)&d_initial_partition, numNodes * sizeof(Vertex));
cudaMemcpy(d_initial_partition, initial_partition, numNodes * sizeof(Vertex), cudaMemcpyHostToDevice);
but I noticed that this operations doesn’t copy the field Edge* of the structure. I’ve tried even to allocate the edge alone like this:
for (int i = 0; i < numNodes; i++) {
Edge* edges;
// 2
cudaMalloc((void **)&edges, initial_partition[i].deg * sizeof(Edge));
// copy edges
if(initial_partition[0].deg != 0){
cudaMemcpy(edges, initial_partition[i].edges, initial_partition[i].deg * sizeof(Edge), cudaMemcpyHostToDevice);
}
cudaMemcpy(&d_initial_partition[i].edges, &edges, sizeof(Edge*), cudaMemcpyHostToDevice);
}
but nothing,it still goes in seg.fault if i try to access to edges fields (end or start). Can someone let me see how can I save all the information in the d_initial_partition vector?
Thank you all