mardi 24 avril 2018

Use CUSP matrix inside CUDA function?

i want to write a kernel function that takes as input 2 CUSP matrices A and B,
then fills data into B in parallel.

#include <cusp/coo_matrix.h>
#include <cusp/print.h>
#include <iostream>

__global__ void kernel_example(cusp::coo_matrix<int,float,cusp::host_memory>* A,
cusp::coo_matrix<int,float,cusp::host_memory>* B){
    printf("hello from kernel...");
    //actual operations go here.
}

int main(void)
{
    // allocate storage
    cusp::coo_matrix<int,float,cusp::host_memory> A(4,3,6);
    cusp::coo_matrix<int,float,cusp::host_memory> B(4,3,6);

    // initialize matrix entries on host
    A.row_indices[0] = 0; A.column_indices[0] = 0; A.values[0] = 10;
    A.row_indices[1] = 0; A.column_indices[1] = 2; A.values[1] = 20;
    A.row_indices[2] = 2; A.column_indices[2] = 2; A.values[2] = 30;
    A.row_indices[3] = 3; A.column_indices[3] = 0; A.values[3] = 40;
    A.row_indices[4] = 3; A.column_indices[4] = 1; A.values[4] = 50;
    A.row_indices[5] = 3; A.column_indices[5] = 2; A.values[5] = 60;

    kernel_example<<<1,1>>>(A,B);
    cudaDeviceSynchronize();    

    return 0;
}

the following error ensues:

error: no suitable conversion function from "cusp::coo_matrix<int, float, cusp::host_memory>" to "cusp::coo_matrix<int, float, cusp::host_memory> *" exists

how do i go about it?

Aucun commentaire:

Enregistrer un commentaire