-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Did some testing with your/harris prefix sum code. I'm wondering if cuda does something different here:
Line 24 in 95ebd2c
| #define CONFLICT_FREE_OFFSET(index) ((index) >> LOG_NUM_BANKS + (index) >> (2*LOG_NUM_BANKS)) |
Should be changed to:
#define CONFLICT_FREE_OFFSET(index) (((index) >> LOG_NUM_BANKS) + ((index) >> (2*LOG_NUM_BANKS)))due to C++ Operator Precedence of + over >>.
Ran this code to test it:
#include <iostream>
#define NUM_BANKS 32
#define LOG_NUM_BANKS 5
#define CONFLICT_FREE_OFFSET_ONCE(n) ((n) >> LOG_NUM_BANKS)
#define CONFLICT_FREE_OFFSET_TWICE(n) (((n) >> LOG_NUM_BANKS) + ((n) >> (2 * LOG_NUM_BANKS)))
#define CONFLICT_FREE_OFFSET_HARRIS(n) ((n) >> LOG_NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS))
int main(){
for(int i=0 ; i<1024;i++){
int ai = i;
int bi = i+1024;
std::cout<< i << " bankOffsetA: " << CONFLICT_FREE_OFFSET_ONCE(ai)<< " bankOffsetB: " << CONFLICT_FREE_OFFSET_ONCE(bi) <<" Fluids" <<std::endl;
std::cout<< i << " bankOffsetA: " << CONFLICT_FREE_OFFSET_TWICE(ai)<< " bankOffsetB: " << CONFLICT_FREE_OFFSET_TWICE(bi) <<" Test" <<std::endl;
std::cout<< i << " bankOffsetA: " << CONFLICT_FREE_OFFSET_HARRIS(ai)<< " bankOffsetB: " << CONFLICT_FREE_OFFSET_HARRIS(bi) <<" Harris" <<std::endl;
std::cout<<std::endl;
}
return 0;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels