common.cuh 746 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
#ifndef THC_COMMON_INC
#define THC_COMMON_INC

#define KERNEL_LOOP(I, N) \
  for (ptrdiff_t I = blockIdx.x * blockDim.x + threadIdx.x; I < N; I += blockDim.x * gridDim.x)

const int MAX_DIMS = 25;
rusty1s's avatar
rusty1s committed
8
const int NUM_THREADS = 1024;
rusty1s's avatar
rusty1s committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

inline int GET_BLOCKS(int N) {
  return (N + NUM_THREADS - 1) / NUM_THREADS;
}

#define KERNEL_REAL_RUN(NAME, N, ...) \
  int grid = GET_BLOCKS(N); \
  cudaStream_t stream = THCState_getCurrentStream(state); \
  NAME<real><<<grid, NUM_THREADS, 0, stream>>>(__VA_ARGS__, N); \
  THCudaCheck(cudaGetLastError())

template<typename T>
struct TensorInfo {
  T *data;
  int dims;
  int size[MAX_DIMS];
  int stride[MAX_DIMS];
};

#include "generic/common.cuh"
#include "THC/THCGenerateAllTypes.h"

#endif // THC_COMMON_INC