Hi! I have these struct:
I have then a list of vertex called
In particular, the
I noticed that the problematic line is the
C:
typedef struct Edge {
int start;
int end;
} Edge;
typedef struct {
int dest;
int deg;
int nome;
Edge *edges;
} Vertex;
typedef struct {
int numberOfVertices;
Vertex *vertices;
} Graph;
initial_partition
and I want to create the d_initial_partition
to pass on the device. the rpoblem is that I'm having problems copying the Edge*
field of the elements of initial_partition
to the elements of d_initial_partition
. As you can see I do:
C:
Vertex* d_initial_partition;
cudaMalloc((void **)&d_initial_partition, numNodes * sizeof(Vertex));
cudaMemcpy(d_initial_partition, initial_partition, numNodes * sizeof(Vertex), cudaMemcpyHostToDevice);
for (int i = 0; i < numNodes; i++) {
Edge* edges;
cudaMalloc((void **)&edges, initial_partition[i].deg * sizeof(Edge));
if(initial_partition[i].deg != 0){
cudaMemcpy(edges, initial_partition[i].edges, initial_partition[i].deg * sizeof(Edge), cudaMemcpyHostToDevice);
cudaMalloc((void**)&(d_initial_partition[i].edges), initial_partition[i].deg * sizeof(Edge));
}
cudaMemcpy(&d_initial_partition[i].edges, &edges, initial_partition[i].deg * sizeof(Edge), cudaMemcpyHostToDevice);
}
In particular, the
edge
variable in the loop takes well the informations, but then the problem is copy these informations into d_initial_partition
.I noticed that the problematic line is the
cudaMalloc
on d_initial_partition
, and I don't understand why I need the presence of &
in the last cudaMemcpy
, which is an operation equal to the other cudaMemcpy
that doesn't use that symbol. I really don't understand this part and I really need to go ahead in my project