hawxgamer

Untitled

Nov 30th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ByMusti
  2.  
  3. __device__ int global_thread_idx_x()
  4. {
  5. return blockIdx.x*blockDim.x + threadIdx.x;
  6. }
  7.  
  8. int ceil_div(int const numerator, int const denominator)
  9. {
  10. auto res = std::div(numerator, denominator);
  11. return res.rem ? (res.quot + 1) : res.quot;
  12. }
  13.  
  14.  
  15. __host__ __device__ __forceinline__
  16. float norm(float3 const & p, float3 const & q) {
  17. float xDist = ((p.x - q.x)*(p.x - q.x));
  18. float yDist = ((p.y - q.y)*(p.y - q.y));
  19. float zDist = ((p.z - q.z)*(p.z - q.z));
  20.  
  21. return (xDist + yDist + zDist); // wir verzichten auf sqrt, da es für uns irrelevant ist
  22. }
  23.  
  24. __host__ __device__ __forceinline__
  25. dim3 blocksPerGrid(dim3 const & block, int3 const & size)
  26. {
  27. return dim3(ceil_div(size.x, block.x), 1, 1);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment