nvGRAPH SSSP example code gives error 8 when using COO as input

I’ve copied the example code (https://docs.nvidia.com/cuda/nvgraph/index.html#nvgraph-sssp-example) 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 (https://docs.nvidia.com/cuda/nvgraph/index.html#nvgraphstatus). 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:

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

I’ve tried to allocate memory for the destination and source edges on the host and copy them 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.

Any tips/advice would be greatly appreciated.

The operation is not supported, just as indicated in the nvGRAPH documentation.

Refer to the answer provided on your cross-posting:

https://stackoverflow.com/questions/52514593/nvgraph-sssp-example-code-gives-error-8-when-using-coo-as-input/52720263#52720263