MaCh3  2.5.0
Reference Guide
gpuUtils.cuh
Go to the documentation of this file.
1 #pragma once
2 
3 // C i/o for printf and others
4 #include <stdio.h>
5 #include <vector>
6 
7 // CUDA specifics
8 // Because CUDA is cuda, need to make sure we don't check C-style floats...
9 #pragma GCC diagnostic push
10 #pragma GCC diagnostic ignored "-Wold-style-cast"
11 #include <cuda_runtime.h>
12 #pragma GCC diagnostic pop
13 
14 #ifdef CUDA_ERROR_CHECK
15 #include <helper_functions.h>
16 #include <helper_cuda.h>
17 #endif
18 
19 // Define the macros
20 #define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
21 #define CudaCheckError() __cudaCheckError(__FILE__, __LINE__)
22 
24 #define _BlockSize_ 1024
25 
30 
33 
34 
35 // **************************************************
36 // ERROR CHECKING ROUTINES
37 // Also exist in helper_cuda.h
38 // **************************************************
39 
45 void __cudaSafeCall( cudaError err, const char *file, const int line );
46 
51 void __cudaCheckError( const char *file, const int line );
52 
53 // *******************************************
54 // Utils
55 // *******************************************
56 
57 // *******************************************
59 void checkGpuMem();
60 
62 void PrintNdevices();
63 
65 void ResetDevice();
66 
69 void SetDevice(const int deviceId);
70 
74 int GetNumGPUThreads(const int Device = 0);
75 
79 size_t GetL2CacheSize(const int device = 0);
80 
84 size_t GetMaxTexture1DSize(const int device = 0);
85 
89 size_t GetSharedMemoryPerBlock(const int device = 0);
90 
91 
92 namespace M3 {
93 #ifdef _LOW_MEMORY_STRUCTS_
94  using float_t = float;
95 #else
96  using float_t = double;
97 #endif
98 }
size_t GetL2CacheSize(const int device=0)
KS: Get L2 cache size (in bytes) for the specified GPU device.
Definition: gpuUtils.cu:120
size_t GetMaxTexture1DSize(const int device=0)
KS: Get the maximum size for 1D textures on the specified GPU device.
Definition: gpuUtils.cu:132
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:83
void ResetDevice()
KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour.
Definition: gpuUtils.cu:75
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:100
void PrintNdevices()
KS: Get some fancy info about GPU.
Definition: gpuUtils.cu:58
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:144
Main namespace for MaCh3 software.
double float_t
Definition: Core.h:37