![]() |
MaCh3
2.5.0
Reference Guide
|
Common CUDA utilities and definitions for shared GPU functionality. More...
#include <stdio.h>#include <vector>#include <cuda_runtime.h>Go to the source code of this file.
Namespaces | |
| M3 | |
| Main namespace for MaCh3 software. | |
Macros | |
| #define | CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__) |
| #define | CudaCheckError() __cudaCheckError(__FILE__, __LINE__) |
| #define | _BlockSize_ 1024 |
| KS: Need it for shared memory, there is way to use dynamic shared memory but I am lazy right now. More... | |
Functions | |
| void | __cudaSafeCall (cudaError err, const char *file, const int line) |
| Check for a safe call on GPU. More... | |
| void | __cudaCheckError (const char *file, const int line) |
| Check if there's been an error. More... | |
| void | checkGpuMem () |
| KS: Get some fancy info about VRAM usage. More... | |
| void | PrintNdevices () |
| KS: Get some fancy info about GPU. More... | |
| void | ResetDevice () |
| KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour. More... | |
| void | SetDevice (const int deviceId) |
| KS: Only useful if using multiple GPU. More... | |
| int | GetNumGPUThreads (const int Device=0) |
| KS: Get number of GPU threads for currently used GPU. More... | |
| size_t | GetL2CacheSize (const int device=0) |
| KS: Get L2 cache size (in bytes) for the specified GPU device. More... | |
| size_t | GetMaxTexture1DSize (const int device=0) |
| KS: Get the maximum size for 1D textures on the specified GPU device. More... | |
| size_t | GetSharedMemoryPerBlock (const int device=0) |
| KS: Returns the maximum shared memory per block for a given GPU device. More... | |
Common CUDA utilities and definitions for shared GPU functionality.
Definition in file gpuUtils.cuh.
| #define _BlockSize_ 1024 |
KS: Need it for shared memory, there is way to use dynamic shared memory but I am lazy right now.
Definition at line 24 of file gpuUtils.cuh.
| #define CudaCheckError | ( | ) | __cudaCheckError(__FILE__, __LINE__) |
Definition at line 21 of file gpuUtils.cuh.
| #define CudaSafeCall | ( | err | ) | __cudaSafeCall(err, __FILE__, __LINE__) |
Definition at line 20 of file gpuUtils.cuh.
| void __cudaCheckError | ( | const char * | file, |
| const int | line | ||
| ) |
Check if there's been an error.
This function checks if there has been any CUDA runtime API error and reports it.
| file | The file name where the error occurred. |
| line | The line number where the error occurred. |
Definition at line 18 of file gpuUtils.cu.
| void __cudaSafeCall | ( | cudaError | err, |
| const char * | file, | ||
| const int | line | ||
| ) |
Check for a safe call on GPU.
KS: There is plenty of useful stuff here https://github.com/NVIDIA/cuda-samples/blob/master/Samples/1_Utilities/deviceQuery/deviceQuery.cpp
KS: We might want to port some of these utilities, for example having bool if there is unified memory etc.
This function checks the error status returned by CUDA runtime API functions and reports any errors.
| err | The CUDA error code. |
| file | The file name where the error occurred. |
| line | The line number where the error occurred. |
Definition at line 6 of file gpuUtils.cu.
| void checkGpuMem | ( | ) |
| size_t GetL2CacheSize | ( | const int | device = 0 | ) |
KS: Get L2 cache size (in bytes) for the specified GPU device.
| device | The ID of the device. Defaults to 0. |
Definition at line 120 of file gpuUtils.cu.
| size_t GetMaxTexture1DSize | ( | const int | device = 0 | ) |
KS: Get the maximum size for 1D textures on the specified GPU device.
| device | The ID of the device. Defaults to 0. |
Definition at line 132 of file gpuUtils.cu.
| int GetNumGPUThreads | ( | const int | Device = 0 | ) |
KS: Get number of GPU threads for currently used GPU.
| Device | The ID of the device. Defaults to 0. |
Definition at line 100 of file gpuUtils.cu.
| size_t GetSharedMemoryPerBlock | ( | const int | device = 0 | ) |
KS: Returns the maximum shared memory per block for a given GPU device.
| device | CUDA device ID (default = 0) |
Definition at line 144 of file gpuUtils.cu.
| void PrintNdevices | ( | ) |
| void ResetDevice | ( | ) |
KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour.
Definition at line 75 of file gpuUtils.cu.
| void SetDevice | ( | const int | deviceId | ) |
KS: Only useful if using multiple GPU.
| deviceId | The ID of the device to be set as active. |
KS: Only useful if using multiple GPU.
Definition at line 83 of file gpuUtils.cu.