#include "xt_cuda.h"
#include <cuda.h>
#include <dlfcn.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "core/core.h"
#include "core/ppm_xfuncs.h"
#include "xt_gpu.h"
Go to the source code of this file.
|
static const char | filename [] = "xt_cuda.c" |
|
static CUresult(* | func_cuGetErrorString )(CUresult error, const char **pStr) |
|
static CUresult(* | func_cuPointerGetAttribute )(void *data, CUpointer_attribute attribute, CUdeviceptr ptr) |
|
static CUresult(* | func_cuMemAlloc )(CUdeviceptr *dptr, size_t bytesize) |
|
static CUresult(* | func_cuMemFree )(CUdeviceptr dptr) |
|
static CUresult(* | func_cuMemcpyDtoD )(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount) |
|
static CUresult(* | func_cuMemcpyHtoD )(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount) |
|
static CUresult(* | func_cuMemcpyDtoH )(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount) |
|
static struct xt_gpu_vtable const | cuda_vtable |
|
◆ CU_ERROR_CHECK
#define CU_ERROR_CHECK |
( |
| ret | ) |
|
Value:do{ \
CUresult err = ret; \
if(err != CUDA_SUCCESS) \
{ \
char const * err_string; \
if (CUDA_SUCCESS != \
err_string = "undefined error"; \
fprintf(stderr, "Cuda driver error %d %s:: %s\n", \
__LINE__, __func__, err_string); \
exit(EXIT_FAILURE); \
} \
} while(0)
static CUresult(* func_cuGetErrorString)(CUresult error, const char **pStr)
Definition at line 86 of file xt_cuda.c.
◆ DLSYM
Value:do { \
if (ptr != NULL) { \
*(
void **)(&(func_ ##
name)) = ptr; \
} else { \
load_successful = false; \
fprintf( \
stderr, "ERROR:failed to load routine \"%s\" " \
} \
} while(0)
Definition at line 73 of file xt_cuda.c.
◆ MAX
#define MAX |
( |
| a, |
|
|
| b ) ((a) >= (b) ? (a) : (b)) |
◆ STRINGIFY
◆ STRINGIFY2
#define STRINGIFY2 |
( |
| x | ) |
#x |
◆ dummy_instr_pop()
static int dummy_instr_pop |
( |
| ) |
|
|
static |
◆ dummy_instr_push()
static int dummy_instr_push |
( |
char const * | XT_UNUSEDname | ) |
|
|
static |
◆ load_cuda_library()
static int load_cuda_library |
( |
void | | ) |
|
|
static |
◆ xt_cuda_free()
static void xt_cuda_free |
( |
void * | ptr, |
|
|
enum xt_memtype | memtype ) |
|
static |
◆ xt_cuda_get_memtype()
static enum xt_memtype xt_cuda_get_memtype |
( |
const void * | ptr | ) |
|
|
static |
◆ xt_cuda_init()
Initialises CUDA
- Returns
- NULL if CUDA could not be initialised
otherwise a valid vtable is returned
Definition at line 314 of file xt_cuda.c.
◆ xt_cuda_malloc()
static void * xt_cuda_malloc |
( |
size_t | alloc_size, |
|
|
enum xt_memtype | memtype ) |
|
static |
◆ xt_cuda_memcpy()
static void xt_cuda_memcpy |
( |
void * | dst, |
|
|
void const * | src, |
|
|
size_t | buffer_size, |
|
|
enum xt_memtype | dst_memtype, |
|
|
enum xt_memtype | src_memtype ) |
|
static |
◆ cuda_vtable
Initial value:= {
}
static int dummy_instr_pop()
static void xt_cuda_free(void *ptr, enum xt_memtype memtype)
static int dummy_instr_push(char const *XT_UNUSED(name))
static void * xt_cuda_malloc(size_t alloc_size, enum xt_memtype memtype)
static void xt_cuda_memcpy(void *dst, void const *src, size_t buffer_size, enum xt_memtype dst_memtype, enum xt_memtype src_memtype)
static enum xt_memtype xt_cuda_get_memtype(const void *ptr)
Definition at line 300 of file xt_cuda.c.
◆ filename
const char filename[] = "xt_cuda.c" |
|
static |
◆ func_cuGetErrorString
CUresult(* func_cuGetErrorString) (CUresult error, const char **pStr) |
( |
CUresult | error, |
|
|
const char ** | pStr ) |
|
static |
◆ func_cuMemAlloc
CUresult(* func_cuMemAlloc) (CUdeviceptr *dptr, size_t bytesize) |
( |
CUdeviceptr * | dptr, |
|
|
size_t | bytesize ) |
|
static |
◆ func_cuMemcpyDtoD
CUresult(* func_cuMemcpyDtoD) (CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount) |
( |
CUdeviceptr | dstDevice, |
|
|
CUdeviceptr | srcDevice, |
|
|
size_t | ByteCount ) |
|
static |
◆ func_cuMemcpyDtoH
CUresult(* func_cuMemcpyDtoH) (void *dstHost, CUdeviceptr srcDevice, size_t ByteCount) |
( |
void * | dstHost, |
|
|
CUdeviceptr | srcDevice, |
|
|
size_t | ByteCount ) |
|
static |
◆ func_cuMemcpyHtoD
CUresult(* func_cuMemcpyHtoD) (CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount) |
( |
CUdeviceptr | dstDevice, |
|
|
const void * | srcHost, |
|
|
size_t | ByteCount ) |
|
static |
◆ func_cuMemFree
CUresult(* func_cuMemFree) (CUdeviceptr dptr) |
( |
CUdeviceptr | dptr | ) |
|
|
static |
◆ func_cuPointerGetAttribute
CUresult(* func_cuPointerGetAttribute) (void *data, CUpointer_attribute attribute, CUdeviceptr ptr) |
( |
void * | data, |
|
|
CUpointer_attribute | attribute, |
|
|
CUdeviceptr | ptr ) |
|
static |