cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

codeboycjy
Journeyman III

Is there a way to modify only part of the stream?

Hi:
   We need to modify part of the stream . Actualy we only need to process some of the elements.
   Take a simple example:
   Here is the data:
   { 1 , 2 , 5 , 2 , 2 , 5 , 6 , 5 , 6  , 8 , 9 , 6 , 3 , 5 }
   I want to change all of the 5 into 50. How could i do that without copying the whole stream to another or using scatter kernel.

0 Likes
6 Replies
gaurav_garg
Adept I

You can probably use read-write aliasing at runtime with BRT_PERMIT_READ_WRITE_ALIASING env variable and use regular input and output stream in kernel.

0 Likes

Actually i've used the varable. There are some questions:
1. How about the performance, we can't afford cost more than 5 ms each call.
2. Is there something else to be set to enable the functionality? Because i've set the varable , but the simple kernel still got error. here is part of the code:

     Stream<float4> data( 2 , dim );
     data.read( cpudata );
     simpleTestKernel( data , data );

     There are some error after the kernel is called.
     Kernel Execution Error: Input stream is same as output stream.
     Binding kernels read-write is prohibited.
     Environment variable BRT_PERMIT_READ_WRITE_ALIASING can be used to allow input-output aliasing.
     But the result can be unpredictable.

3. What does it mean by "But the result can be unpredictable"?

Thanks for ur attension.

0 Likes

It says result can be unpredictable because Stream computing model would not work if you use gather or scatter operations and both input and output are same.

0 Likes

Not sure about Vista, but this environment variable works fine and allows input/output aliasing in XP.

0 Likes

In Vista aliasing works for 1D simple arrays (perhaps, only for them).
It not work for 2D scatter/gather for sure.
0 Likes

Sorry, Posted in wrong thread.

0 Likes