6#include "gpu_types.hpp"
11inline std::string stringprintf(
const char* format, ...) {
13 va_start(args, format);
14 int len = vsnprintf(0, 0, format, args);
21 va_start(args, format);
22 vsnprintf(&text[0], len + 1, format, args);
29 memory_space_device = 0,
34inline std::string device_prop_string(cudaDeviceProp
prop) {
36 cudaGetDevice(&ordinal);
38 size_t freeMem, totalMem;
39 cudaError_t result = cudaMemGetInfo(&freeMem, &totalMem);
40 if(cudaSuccess != result)
throw cuda_exception_t(result);
42 double memBandwidth = (
prop.memoryClockRate * 1000.0) *
43 (
prop.memoryBusWidth / 8 * 2) / 1.0e9;
45 std::string s = stringprintf(
46 "%s : %8.3lf Mhz (Ordinal %d)\n"
47 "%d SMs enabled. Compute Capability sm_%d%d\n"
48 "FreeMem: %6dMB TotalMem: %6dMB %2d-bit pointers.\n"
49 "Mem Clock: %8.3lf Mhz x %d bits (%5.1lf GB/s)\n"
51 prop.name,
prop.clockRate / 1000.0, ordinal,
53 (
int)(freeMem / (1<< 20)), (
int)(totalMem / (1<< 20)), 8 *
sizeof(
int*),
54 prop.memoryClockRate / 1000.0,
prop.memoryBusWidth, memBandwidth,
55 prop.ECCEnabled ?
"Enabled" :
"Disabled");
71 virtual const cudaDeviceProp& props()
const = 0;
72 virtual int ptx_version()
const = 0;
73 virtual cudaStream_t stream() = 0;
76 virtual void* alloc(
size_t size, memory_space_t space) = 0;
77 virtual void free(
void* p, memory_space_t space) = 0;
80 virtual void synchronize() = 0;
82 virtual cudaEvent_t event() = 0;
83 virtual void timer_begin() = 0;
84 virtual double timer_end() = 0;
89__global__
void empty_f() { }
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...