MaCh3  2.2.3
Reference Guide
gpuUtils.cuh
Go to the documentation of this file.
1 #pragma once
2 
3 
4 // C i/o for printf and others
5 #include <stdio.h>
6 #include <vector>
7 
8 // CUDA specifics
9 // Because CUDA is cuda, need to make sure we don't check C-style floats...
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wold-style-cast"
12 #include <cuda_runtime.h>
13 #pragma GCC diagnostic pop
14 
15 #ifdef CUDA_ERROR_CHECK
16 #include <helper_functions.h>
17 #include <helper_cuda.h>
18 #endif
19 
20 // Define the macros
21 #define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
22 #define CudaCheckError() __cudaCheckError(__FILE__, __LINE__)
23 
25 #define _BlockSize_ 1024
26 
27 
32 
35 
36 
37 // **************************************************
38 // ERROR CHECKING ROUTINES
39 // Also exist in helper_cuda.h
40 // **************************************************
41 
47 void __cudaSafeCall( cudaError err, const char *file, const int line );
48 
53 void __cudaCheckError( const char *file, const int line );
54 
55 // *******************************************
56 // Utils
57 // *******************************************
58 
59 // *******************************************
61 void checkGpuMem();
62 
64 void PrintNdevices();
65 
67 void ResetDevice();
68 
71 void SetDevice(const int deviceId);
72 
76 int GetNumGPUThreads(const int Device = 0);
77 
81 size_t GetL2CacheSize(const int device = 0);
82 
86 size_t GetMaxTexture1DSize(const int device = 0);
87 
91 size_t GetSharedMemoryPerBlock(const int device = 0);
size_t GetL2CacheSize(const int device=0)
KS: Get L2 cache size (in bytes) for the specified GPU device.
Definition: gpuUtils.cu:122
size_t GetMaxTexture1DSize(const int device=0)
KS: Get the maximum size for 1D textures on the specified GPU device.
Definition: gpuUtils.cu:134
void __cudaCheckError(const char *file, const int line)
Check if there's been an error.
Definition: gpuUtils.cu:18
void SetDevice(const int deviceId)
KS: Only useful if using multiple GPU.
Definition: gpuUtils.cu:85
void ResetDevice()
KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour.
Definition: gpuUtils.cu:77
void checkGpuMem()
KS: Get some fancy info about VRAM usage.
Definition: gpuUtils.cu:43
int GetNumGPUThreads(const int Device=0)
KS: Get number of GPU threads for currently used GPU.
Definition: gpuUtils.cu:102
void PrintNdevices()
KS: Get some fancy info about GPU.
Definition: gpuUtils.cu:60
void __cudaSafeCall(cudaError err, const char *file, const int line)
Check for a safe call on GPU.
Definition: gpuUtils.cu:6
size_t GetSharedMemoryPerBlock(const int device=0)
KS: Returns the maximum shared memory per block for a given GPU device.
Definition: gpuUtils.cu:146