Created
March 13, 2011 17:26
-
-
Save Kentzo/868275 to your computer and use it in GitHub Desktop.
Right shift for int4
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
| __device__ int4 right_shift_int4(int4 a_value, unsigned int a_num) | |
| { | |
| int x_h = a_value.x >> (a_num % 32); | |
| int x_l = a_value.x << (32 - (a_num %32)); | |
| int y_h = a_value.y >> (a_num % 32); | |
| int y_l = a_value.y << (32 - (a_num % 32)); | |
| int z_h = a_value.z >> (a_num % 32); | |
| int z_l = a_value.z << (32 - (a_num % 32)); | |
| int w_h = a_value.w >> (a_num % 32); | |
| int tmp[8] = {0}; | |
| tmp[4] = x_h; | |
| tmp[5] = x_l | y_h; | |
| tmp[6] = y_l | z_h; | |
| tmp[7] = z_l | w_h; | |
| unsigned int offset = a_num / 32; | |
| return make_int4(tmp[4 - offset], tmp[5 - offset], tmp[6 - offset], tmp[7 - offset]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment