HiRep 0.1
Loading...
Searching...
No Matches
gpu.h
Go to the documentation of this file.
1
5#ifndef GPU_H
6#define GPU_H
7
8#ifdef WITH_GPU
9#define visible __host__ __device__
10#define deviceonly __device__
11#else
12//#define visible inline
13#define visible
14#define deviceonly
15#endif
16
17#ifdef WITH_GPU
18
19#include <stdio.h>
20#ifndef HIP
21#include <cuda.h>
22#include <driver_types.h>
23#include <cuda_runtime.h>
24#include <cuda_runtime_api.h>
25#else
26#include <hip/hip_runtime.h>
27#include <hip/driver_types.h>
28#include <hip/hip_runtime_api.h>
29#endif
30
31#include "IO/input_par.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef struct {
38 unsigned int gpuID;
39 input_record_t read[2]; /* for the reading function */
40} input_gpu;
41
42#ifdef HIP
43#define cudaMalloc hipMalloc
44#define cudaMemcpy hipMemcpy
45#define cudaMemset hipMemset
46#define cub hipcub
47#define cudaGetLastError hipGetLastError
48#define cudaErrorInvalidDevice hipErrorInvalidDevice
49#define cudaErrorPeerAccessAlreadyEnabled hipErrorPeerAccessAlreadyEnabled
50#define cudaErrorInvalidValue hipErrorInvalidValue
51#define cudaStreamDestroy hipStreamDestroy
52#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
53#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
54#define cudaMemcpyHostToHost hipMemcpyHostToHost
55#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
56#define cudaDeviceSynchronize hipDeviceSynchronize
57#define cudaError_t hipError_t
58#define cudaDeviceProp hipDeviceProp_t
59#define cudaSuccess hipSuccess
60#define cudaGetErrorString hipGetErrorString
61#define cudaStreamCreate hipStreamCreate
62#define cudaStream_t hipStream_t
63#define cudaGetDeviceProperties hipGetDeviceProperties
64#define cudaSetDevice hipSetDevice
65#define cudaGetDevice hipGetDevice
66#define cudaDeviceCanAccessPeer hipDeviceCanAccessPeer
67#define cudaDeviceEnablePeerAccess hipDeviceEnablePeerAccess
68#define cudaFree hipFree
69#define cudaGetDeviceCount hipGetDeviceCount
70#define cudaDriverGetVersion hipDriverGetVersion
71#define cudaRuntimeGetVersion hipRuntimeGetVersion
72#define cuDeviceGetAttribute hipDeviceGetAttribute
73#define CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH hipDeviceAttributeMemoryBusWidth
74#define CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE hipDeviceAttributeMemoryClockRate
75#define CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE hipDeviceAttributeL2CacheSize
76#define cudaMemcpyToSymbol hipMemcpyToSymbol
77#endif
78
79#ifndef M_PI
80// Define M_PI if its not part of the C standard
81#define M_PI 3.14159265358979323846264338327
82#endif
83
84// Allow also to use PI for M_PI
85#define PI M_PI
86
87#define init_input_gpu(varname) \
88 { \
89 .read = { { "gpuID", "gpuID = %d", INT_T, &(varname) }, { NULL, NULL, INT_T, NULL } } \
90 }
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif
97#endif
Definition gpu.h:37
Definition input_par.h:15