cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

redditisgreat
Journeyman III

Compiler can't count down :-/

Reverse "for loops" count one short with evergreen GPU code.

After hours of debugging I found the reason my sorting algorithm didn't work.

 

With a given input of A[] = 1, 2, ..., N the following Kernel code gives us for n=16

 

 

sum_total1 = 136;   // correct sum with faulty loop
sum_total2 = 135;   // incorrect sum with correct loop

 

The error persists for larger N, but not for N=8 for example.

All tested on Juniper.

__private uint sum_total1 = 0ul; __private uint sum_total2 = 0ul; for( int i=N-1; i>=-1; --i ){ sum_total1 += A[ i ]; } for( int i=N-1; i>= 0; --i ){ sum_total2 += A[ i ]; }

0 Likes
5 Replies
eklund_n
Journeyman III

that's strange. do you have problems with the >= comparator outside of for loop test clause?

0 Likes

Thanks for reporting this.  I reproduced the problem and filed a bug.

Jeff

0 Likes

That's may be a bug in 2.2 SDK. In 2.1 SDK I see it still count down well.

0 Likes

hi all,

This is a known known issue and you can expect it to be fixed in future releases.

Thanks

0 Likes

hi all,

This is a known known issue and you can expect it to be fixed in future releases.

Thanks

Sorry for the double reply.

0 Likes