1

I copied the example code provided by nvGRAPH to calculate the SSSP, and modified the code such that I am using a COO (rather than a CSC) as the input graph format.

On the line where nvgraphSetGraphStructure is called, I get an ERROR 8 which is a type not supported by this function error. The error description further says that it is usually caused by passing an invalid graph descriptor to the function. However, I don't think that is the case here.

Code example:

  #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;
  }

What I've tried:

Allocate memory for the destination and source edges on the host and copying it to the device. However, since this was not done in the code example provided by nvGRAPH, I don't think it is essential. Nevertheless, I still got an ERROR 8. Just to clarify: running the code as is from the code example from nvGRAPH worked fine.

Moody
  • 851
  • 2
  • 9
  • 23

1 Answers1

2

The error seems clear. COO is not supported. Use CSR or CSC instead. This is mentioned in several places in the nvGraph documentation

For example:

Graphs may be uploaded using the CSR (compressed sparse row) format and the CSC(compressed column storage) format, using nvgraphCreateGraphDescr().

And:

NVGRAPH_COO_32 Coordinate list format with source or destination major. Not used in any algorithm and provided for data storage only.

And:

topologyData Pointer to a filled structure of one of the types {nvgraphCSRTopology32I_t, nvgraphCSCTopology32I_t}. The particular type to be used is defined by parameter TType.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257