Advanced Multi-Physics (AMP)
On-Line Documentation
Namespaces | Macros | Functions
Helper_Cuda.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "AMP/utils/UtilityMacros.h"
#include "AMP/utils/cuda/helper_string.h"
#include "StackTrace/source_location.h"
#include <cuda.h>
#include <cuda_runtime.h>
Include dependency graph for Helper_Cuda.h:

Go to the source code of this file.

Namespaces

namespace  AMP
 
namespace  AMP::Utilities
 

Macros

#define DEVICE_RESET
 
#define deviceBind(...)   checkCudaErrors( cudaSetDevice( __VA_ARGS__ ) )
 
#define deviceFree(...)   checkCudaErrors( cudaFree( __VA_ARGS__ ) )
 
#define deviceGetCount(...)   checkCudaErrors( cudaGetDeviceCount( __VA_ARGS__ ) )
 
#define deviceId(...)   checkCudaErrors( cudaGetDevice( __VA_ARGS__ ) )
 
#define deviceInit(...)   checkCudaErrors( cuInit( __VA_ARGS__ ) )
 
#define deviceMalloc(...)   checkCudaErrors( cudaMalloc( __VA_ARGS__ ) )
 
#define deviceMallocManaged(...)   checkCudaErrors( cudaMallocManaged( __VA_ARGS__ ) )
 
#define deviceMemAttachGlobal   cudaMemAttachGlobal
 
#define deviceMemcpy(...)   checkCudaErrors( cudaMemcpy( __VA_ARGS__ ) )
 
#define deviceMemcpyDeviceToDevice   cudaMemcpyDeviceToDevice
 
#define deviceMemcpyDeviceToHost   cudaMemcpyDeviceToHost
 
#define deviceMemcpyHostToDevice   cudaMemcpyHostToDevice
 
#define deviceMemPrefetchAsync(...)   checkCudaErrors( cudaMemPrefetchAsync( __VA_ARGS__ ) )
 
#define deviceMemset(...)   checkCudaErrors( cudaMemset( __VA_ARGS__ ) )
 
#define deviceSynchronize()   checkCudaErrors( cudaDeviceSynchronize() )
 
#define EXIT_WAIVED   2
 
#define hostDeviceId   cudaCpuDeviceId
 
#define MAX(a, b)   ( a > b ? a : b )
 

Functions

int _ConvertSMVer2Cores (int major, int minor)
 
template<typename T >
void checkCudaErrors (T result, const StackTrace::source_location &source=SOURCE_LOCATION_CURRENT())
 
template<typename T >
const char * cudaGetName (T result)
 
int ftoi (float value)
 
AMP::Utilities::MemoryType getCudaMemoryType (const void *ptr)
 
void getLastDeviceError (const char *errorMessage, const StackTrace::source_location &source=SOURCE_LOCATION_CURRENT())
 
static void setKernelDims (size_t n, dim3 &BlockDim, dim3 &GridDim)
 

Macro Definition Documentation

◆ DEVICE_RESET

#define DEVICE_RESET

Definition at line 48 of file Helper_Cuda.h.

◆ deviceBind

#define deviceBind (   ...)    checkCudaErrors( cudaSetDevice( __VA_ARGS__ ) )

Definition at line 26 of file Helper_Cuda.h.

◆ deviceFree

#define deviceFree (   ...)    checkCudaErrors( cudaFree( __VA_ARGS__ ) )

Definition at line 33 of file Helper_Cuda.h.

◆ deviceGetCount

#define deviceGetCount (   ...)    checkCudaErrors( cudaGetDeviceCount( __VA_ARGS__ ) )

Definition at line 25 of file Helper_Cuda.h.

◆ deviceId

#define deviceId (   ...)    checkCudaErrors( cudaGetDevice( __VA_ARGS__ ) )

Definition at line 27 of file Helper_Cuda.h.

◆ deviceInit

#define deviceInit (   ...)    checkCudaErrors( cuInit( __VA_ARGS__ ) )

Definition at line 24 of file Helper_Cuda.h.

◆ deviceMalloc

#define deviceMalloc (   ...)    checkCudaErrors( cudaMalloc( __VA_ARGS__ ) )

Definition at line 29 of file Helper_Cuda.h.

◆ deviceMallocManaged

#define deviceMallocManaged (   ...)    checkCudaErrors( cudaMallocManaged( __VA_ARGS__ ) )

Definition at line 30 of file Helper_Cuda.h.

◆ deviceMemAttachGlobal

#define deviceMemAttachGlobal   cudaMemAttachGlobal

Definition at line 18 of file Helper_Cuda.h.

◆ deviceMemcpy

#define deviceMemcpy (   ...)    checkCudaErrors( cudaMemcpy( __VA_ARGS__ ) )

Definition at line 31 of file Helper_Cuda.h.

◆ deviceMemcpyDeviceToDevice

#define deviceMemcpyDeviceToDevice   cudaMemcpyDeviceToDevice

Definition at line 22 of file Helper_Cuda.h.

◆ deviceMemcpyDeviceToHost

#define deviceMemcpyDeviceToHost   cudaMemcpyDeviceToHost

Definition at line 21 of file Helper_Cuda.h.

◆ deviceMemcpyHostToDevice

#define deviceMemcpyHostToDevice   cudaMemcpyHostToDevice

Definition at line 20 of file Helper_Cuda.h.

◆ deviceMemPrefetchAsync

#define deviceMemPrefetchAsync (   ...)    checkCudaErrors( cudaMemPrefetchAsync( __VA_ARGS__ ) )

Definition at line 34 of file Helper_Cuda.h.

◆ deviceMemset

#define deviceMemset (   ...)    checkCudaErrors( cudaMemset( __VA_ARGS__ ) )

Definition at line 32 of file Helper_Cuda.h.

◆ deviceSynchronize

#define deviceSynchronize ( )    checkCudaErrors( cudaDeviceSynchronize() )

Definition at line 28 of file Helper_Cuda.h.

◆ EXIT_WAIVED

#define EXIT_WAIVED   2

Definition at line 38 of file Helper_Cuda.h.

◆ hostDeviceId

#define hostDeviceId   cudaCpuDeviceId

Definition at line 16 of file Helper_Cuda.h.

◆ MAX

#define MAX (   a,
 
)    ( a > b ? a : b )

Definition at line 75 of file Helper_Cuda.h.

Function Documentation

◆ _ConvertSMVer2Cores()

int _ConvertSMVer2Cores ( int  major,
int  minor 
)
inline

Definition at line 85 of file Helper_Cuda.h.

◆ checkCudaErrors()

template<typename T >
void checkCudaErrors ( result,
const StackTrace::source_location &  source = SOURCE_LOCATION_CURRENT() 
)

◆ cudaGetName()

template<typename T >
const char * cudaGetName ( result)

◆ ftoi()

int ftoi ( float  value)
inline

Definition at line 79 of file Helper_Cuda.h.

◆ getCudaMemoryType()

AMP::Utilities::MemoryType getCudaMemoryType ( const void *  ptr)

◆ getLastDeviceError()

void getLastDeviceError ( const char *  errorMessage,
const StackTrace::source_location &  source = SOURCE_LOCATION_CURRENT() 
)

◆ setKernelDims()

static void setKernelDims ( size_t  n,
dim3 &  BlockDim,
dim3 &  GridDim 
)
inlinestatic

Definition at line 139 of file Helper_Cuda.h.



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page