Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bank conflicts #7

Open
MeyerFabian opened this issue Oct 15, 2018 · 0 comments
Open

bank conflicts #7

MeyerFabian opened this issue Oct 15, 2018 · 0 comments

Comments

@MeyerFabian
Copy link

Did some testing with your/harris prefix sum code. I'm wondering if cuda does something different here:

#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant