![]() |
MaCh3 2.2.1
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.
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. | |
Functions | |
void | __cudaSafeCall (cudaError err, const char *file, const int line) |
Check for a safe call on GPU. | |
void | __cudaCheckError (const char *file, const int line) |
Check if there's been an error. | |
void | checkGpuMem () |
KS: Get some fancy info about VRAM usage. | |
void | PrintNdevices () |
KS: Get some fancy info about GPU. | |
void | ResetDevice () |
KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour. | |
void | SetDevice (const int deviceId) |
KS: Only useful if using multiple GPU. | |
int | GetNumGPUThreads (const int Device=0) |
KS: Get number of GPU threads for currently used GPU. | |
size_t | GetL2CacheSize (const int device=0) |
KS: Get L2 cache size (in bytes) for the specified GPU device. | |
size_t | GetMaxTexture1DSize (const int device=0) |
KS: Get the maximum size for 1D textures on the specified GPU device. | |
size_t | GetSharedMemoryPerBlock (const int device=0) |
KS: Returns the maximum shared memory per block for a given GPU device. | |
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 25 of file gpuUtils.cuh.
#define CudaCheckError | ( | ) | __cudaCheckError(__FILE__, __LINE__) |
Definition at line 22 of file gpuUtils.cuh.
#define CudaSafeCall | ( | err | ) | __cudaSafeCall(err, __FILE__, __LINE__) |
Definition at line 21 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 | ( | ) |
KS: Get some fancy info about VRAM usage.
Definition at line 43 of file gpuUtils.cu.
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 122 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 134 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 102 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 146 of file gpuUtils.cu.
void PrintNdevices | ( | ) |
KS: Get some fancy info about GPU.
Definition at line 60 of file gpuUtils.cu.
void ResetDevice | ( | ) |
KS: Completely clean GPU, this is time consuming and may lead to unexpected behaviour.
Definition at line 77 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 85 of file gpuUtils.cu.