OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
cudify_hardware_cpu.hpp
1#ifndef CUDIFY_HARDWARE_COMMON_HPP_
2#define CUDIFY_HARDWARE_COMMON_HPP_
3
4
5#include <initializer_list>
6#include <cstring>
7#include "util/cuda_util.hpp"
8
9#if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
10
11#ifndef OPENMP_MAX_NUM_THREADS
12#define OPENMP_MAX_NUM_THREADS 896
13#endif
14
18enum cudaError
19{
20
21 cudaSuccess = 0,
22 cudaErrorInvalidValue = 1,
23 cudaErrorMemoryAllocation = 2,
24 cudaErrorInitializationError = 3,
25 cudaErrorCudartUnloading = 4,
26 cudaErrorProfilerDisabled = 5,
27 cudaErrorProfilerNotInitialized = 6,
28 cudaErrorProfilerAlreadyStarted = 7,
29 cudaErrorProfilerAlreadyStopped = 8,
30 cudaErrorInvalidConfiguration = 9,
31 cudaErrorInvalidPitchValue = 12,
32 cudaErrorInvalidSymbol = 13,
33 cudaErrorInvalidHostPointer = 16,
34 cudaErrorInvalidDevicePointer = 17,
35 cudaErrorInvalidTexture = 18,
36 cudaErrorInvalidTextureBinding = 19,
37 cudaErrorInvalidChannelDescriptor = 20,
38 cudaErrorInvalidMemcpyDirection = 21,
39 cudaErrorAddressOfConstant = 22,
40 cudaErrorTextureFetchFailed = 23,
41 cudaErrorTextureNotBound = 24,
42 cudaErrorSynchronizationError = 25,
43 cudaErrorInvalidFilterSetting = 26,
44 cudaErrorInvalidNormSetting = 27,
45 cudaErrorMixedDeviceExecution = 28,
46 cudaErrorNotYetImplemented = 31,
47 cudaErrorMemoryValueTooLarge = 32,
48 cudaErrorStubLibrary = 34,
49 cudaErrorInsufficientDriver = 35,
50 cudaErrorCallRequiresNewerDriver = 36,
51 cudaErrorInvalidSurface = 37,
52 cudaErrorDuplicateVariableName = 43,
53 cudaErrorDuplicateTextureName = 44,
54 cudaErrorDuplicateSurfaceName = 45,
55 cudaErrorDevicesUnavailable = 46,
56 cudaErrorIncompatibleDriverContext = 49,
57 cudaErrorMissingConfiguration = 52,
58 cudaErrorPriorLaunchFailure = 53,
59 cudaErrorLaunchMaxDepthExceeded = 65,
60 cudaErrorLaunchFileScopedTex = 66,
61 cudaErrorLaunchFileScopedSurf = 67,
62 cudaErrorSyncDepthExceeded = 68,
63 cudaErrorLaunchPendingCountExceeded = 69,
64 cudaErrorInvalidDeviceFunction = 98,
65 cudaErrorNoDevice = 100,
66 cudaErrorInvalidDevice = 101,
67 cudaErrorDeviceNotLicensed = 102,
68 cudaErrorSoftwareValidityNotEstablished = 103,
69 cudaErrorStartupFailure = 127,
70 cudaErrorInvalidKernelImage = 200,
71 cudaErrorDeviceUninitialized = 201,
72 cudaErrorMapBufferObjectFailed = 205,
73 cudaErrorUnmapBufferObjectFailed = 206,
74 cudaErrorArrayIsMapped = 207,
75 cudaErrorAlreadyMapped = 208,
76 cudaErrorNoKernelImageForDevice = 209,
77 cudaErrorAlreadyAcquired = 210,
78 cudaErrorNotMapped = 211,
79 cudaErrorNotMappedAsArray = 212,
80 cudaErrorNotMappedAsPointer = 213,
81 cudaErrorECCUncorrectable = 214,
82 cudaErrorUnsupportedLimit = 215,
83 cudaErrorDeviceAlreadyInUse = 216,
84 cudaErrorPeerAccessUnsupported = 217,
85 cudaErrorInvalidPtx = 218,
86 cudaErrorInvalidGraphicsContext = 219,
87 cudaErrorNvlinkUncorrectable = 220,
88 cudaErrorJitCompilerNotFound = 221,
89 cudaErrorUnsupportedPtxVersion = 222,
90 cudaErrorJitCompilationDisabled = 223,
91 cudaErrorUnsupportedExecAffinity = 224,
92 cudaErrorInvalidSource = 300,
93 cudaErrorFileNotFound = 301,
94 cudaErrorSharedObjectSymbolNotFound = 302,
95 cudaErrorSharedObjectInitFailed = 303,
96 cudaErrorOperatingSystem = 304,
97 cudaErrorInvalidResourceHandle = 400,
98 cudaErrorIllegalState = 401,
99 cudaErrorSymbolNotFound = 500,
100 cudaErrorNotReady = 600,
101 cudaErrorIllegalAddress = 700,
102 cudaErrorLaunchOutOfResources = 701,
103 cudaErrorLaunchTimeout = 702,
104 cudaErrorLaunchIncompatibleTexturing = 703,
105 cudaErrorPeerAccessAlreadyEnabled = 704,
106 cudaErrorPeerAccessNotEnabled = 705,
107 cudaErrorSetOnActiveProcess = 708,
108 cudaErrorContextIsDestroyed = 709,
109 cudaErrorAssert = 710,
110 cudaErrorTooManyPeers = 711,
111 cudaErrorHostMemoryAlreadyRegistered = 712,
112 cudaErrorHostMemoryNotRegistered = 713,
113 cudaErrorHardwareStackError = 714,
114 cudaErrorIllegalInstruction = 715,
115 cudaErrorMisalignedAddress = 716,
116 cudaErrorInvalidAddressSpace = 717,
117 cudaErrorInvalidPc = 718,
118 cudaErrorLaunchFailure = 719,
119 cudaErrorCooperativeLaunchTooLarge = 720,
120 cudaErrorNotPermitted = 800,
121 cudaErrorNotSupported = 801,
122 cudaErrorSystemNotReady = 802,
123 cudaErrorSystemDriverMismatch = 803,
124 cudaErrorCompatNotSupportedOnDevice = 804,
125 cudaErrorMpsConnectionFailed = 805,
126 cudaErrorMpsRpcFailure = 806,
127 cudaErrorMpsServerNotReady = 807,
128 cudaErrorMpsMaxClientsReached = 808,
129 cudaErrorMpsMaxConnectionsReached = 809,
130 cudaErrorStreamCaptureUnsupported = 900,
131 cudaErrorStreamCaptureInvalidated = 901,
132 cudaErrorStreamCaptureMerge = 902,
133 cudaErrorStreamCaptureUnmatched = 903,
134 cudaErrorStreamCaptureUnjoined = 904,
135 cudaErrorStreamCaptureIsolation = 905,
136 cudaErrorStreamCaptureImplicit = 906,
137 cudaErrorCapturedEvent = 907,
138 cudaErrorStreamCaptureWrongThread = 908,
139 cudaErrorTimeout = 909,
140 cudaErrorGraphExecUpdateFailure = 910,
141 cudaErrorUnknown = 999,
142 cudaErrorApiFailureBase = 10000
143};
144
145typedef cudaError cudaError_t;
146
147struct uint3
148{
149 unsigned int x, y, z;
150};
151
152struct dim3
153{
154 unsigned int x, y, z;
155
156 constexpr dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}
157 constexpr dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {}
158 constexpr operator uint3(void) const { return uint3{x, y, z}; }
159
160 constexpr dim3(const dim3 & d) : x(d.x), y(d.y), z(d.z) {}
161
162 template<typename T>
163 dim3(const std::initializer_list<T> & list)
164 {
165 auto it = list.begin();
166
167 x = *it;
168 ++it;
169 y = *it;
170 ++it;
171 z = *it;
172 }
173};
174
178enum cudaMemcpyKind
179{
180 cudaMemcpyHostToHost = 0,
181 cudaMemcpyHostToDevice = 1,
182 cudaMemcpyDeviceToHost = 2,
183 cudaMemcpyDeviceToDevice = 3,
184 cudaMemcpyDefault = 4
185};
186
187const static char unk_error[] = "Unknown error";
188
189static const char* cudaGetErrorName ( cudaError error )
190{
191 return unk_error;
192}
193
194static const char* cudaGetErrorString ( cudaError error )
195{
196 return unk_error;
197}
198
199static void cudaDeviceSynchronize()
200{}
201
202static cudaError cudaMemcpyFromSymbol(void * dev_mem,const unsigned char * global_cuda_error_array,size_t sz)
203{
204 memcpy(dev_mem,global_cuda_error_array,sz);
205 return cudaError::cudaSuccess;
206}
207
208static cudaError cudaMemcpyToSymbol(unsigned char * global_cuda_error_array, const void * dev_mem,size_t sz, size_t offset = 0, cudaMemcpyKind kind = cudaMemcpyHostToDevice )
209{
210 memcpy(global_cuda_error_array + offset,dev_mem,sz);
211 return cudaError::cudaSuccess;
212}
213
214static cudaError cudaMemcpy( void* dst, const void* src, size_t count, cudaMemcpyKind kind)
215{
216 memcpy(dst,src,count);
217
218 return cudaError::cudaSuccess;
219}
220
221
222static cudaError cudaHostGetDevicePointer( void** pDevice, void* pHost, unsigned int flags)
223{
224 *pDevice = pHost;
225
226 return cudaError::cudaSuccess;
227}
228
229struct float3
230{
231 float x,y,z;
232};
233
234struct float4
235{
236 float x,y,z,w;
237};
238
239static __inline__ __host__ __device__ float4 make_float4(float x, float y, float z, float w)
240{
241 float4 t; t.x = x; t.y = y; t.z = z; t.w = w; return t;
242}
243
244
245
246#endif
247
248#endif