Ricardo Loreto
Ricardo Loreto

Reputation: 11

How can it be possible that my Cuda Vector is empty after just filling it?

So I have this chunk of Code which is meant to be a plugin of a library for a future unity Asset. The library fills a mesh with tetrahedrons using a set of tridimensional points. I pass the points from Unity and everything works just fine the vector apparently fills up,or so says my log textfile...After the writting,before I try to call the tetraedralization method I check for the vector not to be empty and it turns out that it is empty. I Do not understand.

I never used dll communication so I am a bit lost. Thank you for your time.

Here is the code:

extern "C"{
const int deviceIdx     = 0; 
const int seed          = 123456789;
const int pointNum      = 15000;
const Distribution dist = UniformDistribution;

Point3HVec   pointVec; 
GDelOutput   output; 

EXPORT_API void makeInputFromMeshCoords(float x[] , float y[], float z[],int sizeOfArrays){
     CudaSafeCall( cudaSetDevice( deviceIdx ) );
     CudaSafeCall( cudaDeviceReset() );
    std::ofstream StatisticsFile;
    StatisticsFile.open ("E:/documentos/Videojuegos/Cuarto_curso/TFG/SimplestPluginExample/Unity Project Plugin/Assets/Logs/CoordinatesUnity.txt"); 

    for(int i =0; i<sizeOfArrays;i++)
     {            

          Point3 point = {x[i],y[i],z[i]};
          pointVec.push_back(point);
          StatisticsFile <<"("<<pointVec[i]._p[0]<<","<<pointVec[i]._p[1]<<","<<pointVec[i]._p[2]<<")"<< std::endl;     
          StatisticsFile<<pointVec.size()<<std::endl; 
    }
    StatisticsFile<<"END OF LOOP; SIZE: "<<pointVec.size()<<"Empty " << (pointVec.empty()?"it is":"it is not")<<std::endl; 
    StatisticsFile.close();

    assert(pointVec.empty());
    GpuDel triangulator; 
    triangulator.compute( pointVec, &output );
}

}

Here are the library type definitions:

typedef thrust::host_vector< Point3 >    Point3HVec;

Upvotes: 0

Views: 69

Answers (1)

cnettel
cnettel

Reputation: 1024

The argument to assert is an expression you assert to be true under proper operation. You assert that the vector is empty, which fails, since it is in fact populated. Remove the assert or change it to assert(!pointVec.empty());.

Upvotes: 3

Related Questions