c++ - Failure to allocate memory resulting in segmentation fault -


I am developing in C ++ and Opansiel this test application would but I did not know that I find it very strange Why is getting the issue proceeds in the segmentation fault

some code:

  output = new cl_float [TestCount * TrainCount]; // Output array output_buf = new cl :: buffer (* reference, CL_MEM_WRITE_ONLY, size (cl_float) * testcount * traincount, tap); // .... some more accessories queue- & gt; Encurred buffer (* output_book, CLTTRR, 0, testcount * traincount, output);   

Here, the output and output_buffs are signs of their respective data.

The seg-fault occurs when I try to access an element of the output array after all processed. On the next debugging, I came to know that it stores the maximum 562 elements, while it should be 2250 (TestCount = 150, Train Count = 15). Apart from this, surprisingly, I can use any element from GDB, but not above 562.

I have no problem no doubt that code and I being processed by making sure that all the 2250 output GPU is completed to increase the first element of the output array for each thread of nuclear and Then he was doing test by producing it through GDB.

It seems like I've turned down a lot of possibilities, but it is what I have been filled with a low chance that ads are still "do not know what caused the problem, but I looked upwards and found that my application only uses 37M memory.

Any help would be appreciated! Update

: James is right it did not read enough bytes of memory Manohar-fault of Bakstrakt follows -

  Program received signal EXC_BAD_ACCESS, could not access the memory cause address KERN_INVALID_ADDRESS: 0x000000000000000c in 0x0000000100002402 main (argc = 4, argv = 0x7fff5fbffb88) on TestApplication.cpp: 202 202 cout & lt; & Lt; OpenCL_KNN :: Output [0] & lt; & Lt; "" & Lt; & Lt; OpenCL_KNN :: Output [1] & lt; & Lt; "" & Lt; & Lt; OpenCL_KNN :: Output [2] & lt; & Lt; "" & Lt; & Lt; OpenCL_KNN :: Product [3];   

Access to the 4 index is definitely defined. Anything before this line gives me no error

Update 2 : The error has been solved. It just happened in Mac OS X. Something was done to do this, the way I was reaching the output. After returning to output in OpenCL_KNN space, I worked perfectly, it worked perfectly.

I am not familiar with C ++ wrapper for CL, but I think the TestCount * Train Count , sizeof (cl_float) is a factor of very few bytes to read from the GPU. Your code should be:

  queue-> EnqueueReadBuffer (* output_buf, CL_TRUE, 0, size (cl_float) * TestCount * TrainCount, Output);   

This does not explain your segfault, however. Maybe you're making a mistake somewhere else?

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -