cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

gentiradentes
Journeyman III

Problems with Stream Wrapper Object

I've recently written a wrapper object for Brook+ streams that makes the process of performing simple data parallel operations easier. The wrapper provides overloaded operators that work with streams, which makes porting SISD code to the GPU much easier than ever before.

 

Here is the code: (This is GPLv3 licensed, by the way.

Kernel

StreamOperations Header

StreamOperations Source

The problem I'm having is that I need to return a streamOperations object for each call of an overloaded operator which contains the results of the operation. I need the "stream" and "result" streams to be accessible and constant throughout the class, so I create pointers to them and dynamically allocate the streams during the construction of the object.

This is causing me problems because for some reason, attempting to delete the streams in the destructor causes the application to crash. If I don't delete the streams, a memory leak appears on the GPU side, and graphics memory is consumed until the application crashes. (This happens in seconds) Besides these problems, the wrapper works great.

If anyone can help me solve this problem, I'd be very grateful. This code, like I said, is licensed under the GNU GPLv3, so if I can fix this, you'd not only be helping me, you'd also be helping anyone else who would benefit from this code.

Thanks.

//Here's an example of how the wrapper is used: int size = 4096; int* input = new int[size]; int* output = new int[size]; for(int i = 0; i < size; i++) { input = i; } //CPU Code: for(int i = 0; i < size; i++) output = input + input; //GPU Code: (using streamOperations wrapper) streamOperations ops(size); ops.writeStream(input); ops += ops; ops.readStream(output);

0 Likes
1 Reply
gaurav_garg
Adept I

Stream operator= and copy constructors use shallow copying for internal objects. Hope this information may help you in debug the problem.

0 Likes