Last active
December 19, 2015 14:49
-
-
Save allanmac/5972461 to your computer and use it in GitHub Desktop.
Difference between 4 sequential 32-bit loads and 1 128-bit (4x32-bit) vector load.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define KERNEL_QUALIFIERS extern "C" __global__ | |
| // | |
| // | |
| // | |
| #define REPEAT1() \ | |
| REPS(0) | |
| #define REPEAT4() \ | |
| REPS(0) \ | |
| REPS(1) \ | |
| REPS(2) \ | |
| REPS(3) | |
| // | |
| // | |
| // | |
| KERNEL_QUALIFIERS | |
| void | |
| mem4(const float* const fin, float* const fout) | |
| { | |
| const unsigned int tidx = threadIdx.x * 4; | |
| #undef REPS | |
| #define REPS(n) const float f##n = fin[tidx+n]; | |
| REPEAT4(); | |
| #undef REPS | |
| #define REPS(n) fout[tidx+n] = f##n; | |
| REPEAT4(); | |
| } | |
| // | |
| // | |
| // | |
| KERNEL_QUALIFIERS | |
| void | |
| mem1(const float4* const fin, float4* const fout) | |
| { | |
| const unsigned int tidx = threadIdx.x; | |
| #undef REPS | |
| #define REPS(n) const float4 f##n = fin[tidx+n]; | |
| REPEAT1(); | |
| #undef REPS | |
| #define REPS(n) fout[tidx+n] = f##n; | |
| REPEAT1(); | |
| } | |
| // | |
| // | |
| // |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiled with:
nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin mem4.cuDumped with:
nvdisasm -c mem4.cubin