0

all. I am wondering about how to allocation double pointer to cuda. My code is below.

------------this is structure---

typedef struct vertex vertex;

struct vertex {
    unsigned int vertex_id;
    float pagerank;
    float pagerank_next;
    unsigned int n_successors;
    vertex ** successors;
};

------------these are vertics----

vertex * vertices;
vertices = (vertex *)malloc(n_vertices * sizeof(vertex));
vertex *d_vertices;
cudaMalloc((void **)&d_vertices, n_vertices * sizeof(vertex));

---------these are vertics' succesors. It means double pointers----

vertices[i].successors = (vertex**)malloc(vertices[i].n_successors*sizeof(vertex *));
cudaMalloc((void ***)&d_vertices[i].successors, vertices[i].n_successors * sizeof(vertex *)); // error part.

When I allocate cudaMalloc((void ***)&d_vertices[i].successors, vertices[i].n_successors * sizeof(vertex *));

Visual Studio is stopped... I guess pointer error. But I don't know how to double pointer allocation in cuda. Please, let me know what's wrong in that code. Thank you so much.

best regards

talonmies
  • 70,661
  • 34
  • 192
  • 269

0 Answers0