Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cuda.h"
- #include <stdio.h>
- #include <math.h>
- __global__ void fp_test(int a, int b, float c)
- {
- int val_gpu = ceilf( (a+b) * c / (1.0f+c) );
- printf("gpu: %dn", val_gpu);
- }
- int main()
- {
- int a = 5;
- int b = 4;
- float c = 0.8;
- fp_test<<<1,1>>>(a, b, c);
- cudaDeviceSynchronize();
- int val_cpu = ceilf( (a+b) * c / (1.0+c) );
- printf("cpu: %dn", val_cpu);
- }
- $ nvcc -arch=sm_20 gpu_fp_test.cu -o gpu_fp_test
- $ gpu_fp_test
- gpu: 5
- cpu: 4
- int val_gpu = ceilf( (a+b) * c / (1.0+c) );
- ^
- remove f from constant
- int val_cpu = ceilf( (a+b) * c / (1.0f+c) );
- ^
- add f to constant
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement