-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
31 lines (24 loc) · 884 Bytes
/
util.h
File metadata and controls
31 lines (24 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CUDA_UTIL_H_
#define CUDA_UTIL_H_
#include <cuda_runtime.h>
#include "gpu_ptr.h"
/**
* Calculates the address based on input parameters
*/
__host__ float* address2D(float* base, unsigned int pitch, unsigned int x, unsigned int y) {
return (float*) ((char*) base+y*pitch) + x;
}
/**
* Calculates the address based on input parameters
* @param base The start pointer of the array
* @param pitch number of bytes in each row
* @param x offset in elements to x direction
* @param y offset in elements in y direction
*/
__device__ float* device_address2D(float* base, unsigned int pitch, unsigned int x, unsigned int y) {
return (float*) ((char*) base+y*pitch) + x;
}
__device__ float* global_index(float* base, unsigned int pitch, int x, int y, int border = 0) {
return (float*) ((char*) base+(y+border)*pitch) + (x+border);
}
#endif