Я скопировал пример кода , предоставленный nvGRAPH для вычисления SSSP, и изменил код так, что я использую COO (а не CSC) в качестве формата входного графика.
В строке, где вызывается nvgraphSetGraphStructure
, я получаю ERROR 8
, тип , не поддерживаемый этой функцией error.Далее в описании ошибки говорится, что оно обычно вызывается передачей недопустимого дескриптора графа в функцию.Однако я не думаю, что это так.
Пример кода:
#include <stdio.h>
#include <cuda_runtime.h>
#include <nvgraph.h>
#include <curand.h>
#include <curand_kernel.h>
#include <iostream>
void check(nvgraphStatus_t status) {
if (status != NVGRAPH_STATUS_SUCCESS) {
printf("ERROR : %d\n", status);
exit(0);
}
}
int main(int argc, char **argv) {
const size_t n = 6, nnz = 10, vertex_numsets = 1, edge_numsets = 1;
float *sssp_1_h;
void** vertex_dim;
// nvgraph variables
nvgraphStatus_t status;
nvgraphHandle_t handle;
nvgraphGraphDescr_t graph;
nvgraphCOOTopology32I_t COO_input;
cudaDataType_t edge_dimT = CUDA_R_32F;
cudaDataType_t* vertex_dimT;
// Init host data
sssp_1_h = (float*)malloc(n*sizeof(float));
vertex_dim = (void**)malloc(vertex_numsets*sizeof(void*));
vertex_dimT = (cudaDataType_t*)malloc(vertex_numsets*sizeof(cudaDataType_t));
COO_input = (nvgraphCOOTopology32I_t) malloc(sizeof(struct nvgraphCOOTopology32I_st));
vertex_dim[0]= (void*)sssp_1_h;
vertex_dimT[0] = CUDA_R_32F;
int source_indices_h[] = {2, 0, 2, 0, 4, 5, 2, 3, 3, 4};
int destination_indices_h[] = {0, 1, 1, 2, 3, 3, 4, 4, 5, 5};
float weights_h[] = {0.333333, 0.5, 0.333333, 0.5, 0.5, 1.0, 0.333333, 0.5, 0.5, 0.5};
check(nvgraphCreate(&handle));
check(nvgraphCreateGraphDescr (handle, &graph));
COO_input->nvertices = n;
COO_input->nedges = nnz;
COO_input->source_indices = source_indices_h;
COO_input->destination_indices = destination_indices_h;
COO_input->tag = NVGRAPH_UNSORTED;
// Set graph connectivity and properties (tranfers)
check(nvgraphSetGraphStructure(handle, graph, (void*)COO_input, NVGRAPH_COO_32)); // Error 8 occurs here
check(nvgraphAllocateVertexData(handle, graph, vertex_numsets, vertex_dimT));
check(nvgraphAllocateEdgeData (handle, graph, edge_numsets, &edge_dimT));
check(nvgraphSetEdgeData(handle, graph, (void*)weights_h, 0));
// Solve
int source_vert = 0;
check(nvgraphSssp(handle, graph, 0, &source_vert, 0));
// Get and print result
check(nvgraphGetVertexData(handle, graph, (void*)sssp_1_h, 0));
// Clean
free(sssp_1_h);
free(vertex_dim);
free(vertex_dimT);
free(COO_input);
check(nvgraphDestroyGraphDescr(handle, graph));
check(nvgraphDestroy(handle));
return 0;
}
Что я пробовал:
Выделить память для конечного и исходного реберна хосте и копирование его на устройство.Однако, поскольку это не было сделано в примере кода, предоставленном nvGRAPH, я не думаю, что это существенно.Тем не менее, я все еще получил ERROR 8
.Просто чтобы уточнить: запуск кода как есть из примера кода из nvGRAPH работал нормально.