this file provides tools to CarmaObj
More...
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <driver_types.h>
#include <vector_types.h>
#include <chrono>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cuda.h>
#include <cuda_fp16.h>
#include <cuda_runtime_api.h>
#include <cufft.h>
Go to the source code of this file.
|
#define | CARMA_PI 3.1415926535897932384626433832 |
|
#define | DEBUG_TRACE(fmt, args...) fprintf(stderr, "[%s@%d]: " fmt "\n", __FILE__, __LINE__, ##args) |
|
#define | CAST(type, new_var, var) type new_var = dynamic_cast<type>(var) |
|
#define | SCAST(type, new_var, var) type new_var = static_cast<type>(var) |
|
#define | carma_safe_call_no_sync(err) err |
|
#define | carma_safe_call(err) err |
|
#define | carma_safe_device_synchronize() cudaDeviceSynchronize() |
|
#define | carmafft_safe_call(err) err |
|
#define | cutil_check_error(err) err |
|
#define | carma_check_msg(msg) |
|
#define | cutil_safe_malloc(mallocCall) (mallocCall) |
|
#define | MIN(a, b) ((a < b) ? a : b) |
|
#define | MAX(a, b) ((a > b) ? a : b) |
|
|
template<typename T > |
std::string | carma_utils::to_string (const T &n) |
|
template<typename T > |
T | carma_utils::from_string (const std::string &myString) |
|
void | carma_utils::split (std::vector< std::string > &tokens, const std::string &text, char sep) |
|
unsigned int | next_pow2 (unsigned int x) |
|
bool | is_pow2 (unsigned int x) |
|
void | get_num_blocks_and_threads (CarmaDevice *device, int n, int &blocks, int &threads) |
|
void | sum_get_num_blocks_and_threads (int n, CarmaDevice *device, int &blocks, int &threads) |
|
template<class T_data > |
int | find_nnz (T_data *d_data, int *tmp_colind, int N, int *d_nnz, int &h_nnz, CarmaDevice *device) |
|
template<class T_data > |
int | fill_sparse_vect (T_data *dense_data, int *colind_sorted, T_data *values, int *colind, int *rowind, int nnz, CarmaDevice *device) |
|
int | float_to_double (float *idata, double *odata, int N, CarmaDevice *device) |
|
int | double_to_float (double *idata, float *odata, int N, CarmaDevice *device) |
|
int | print_mem_info () |
|
template<typename T_data > |
int | fill_array_with_value (T_data *d_data, T_data value, int N, CarmaDevice *device) |
|
void | carma_start_profile () |
|
void | carma_stop_profile () |
|
void | __carma_safe_call_no_sync (cudaError err, const char *file, const int line) |
|
void | __carma_safe_call (cudaError err, const char *code, const char *file, const int line) |
|
void | __carma_safe_device_synchronize (const char *file, const int line) |
|
void | __carmafft_safe_call (cufftResult err, const char *file, const int line) |
|
void | __carma_check_msg (const char *error_message, const char *file, const int line) |
|
void | __carma_safe_malloc (void *pointer, const char *file, const int line) |
|
this file provides tools to CarmaObj
- Author
- COMPASS Team https://github.com/ANR-COMPASS
- Version
- 5.0.0
- Date
- 2011/01/28
- Copyright
- GNU Lesser General Public License
Definition in file carma_utils.h.
◆ carma_check_msg
#define carma_check_msg |
( |
|
msg | ) |
|
◆ CARMA_PI
#define CARMA_PI 3.1415926535897932384626433832 |
◆ carma_safe_call
#define carma_safe_call |
( |
|
err | ) |
err |
◆ carma_safe_call_no_sync
#define carma_safe_call_no_sync |
( |
|
err | ) |
err |
◆ carma_safe_device_synchronize
#define carma_safe_device_synchronize |
( |
| ) |
cudaDeviceSynchronize() |
◆ carmafft_safe_call
#define carmafft_safe_call |
( |
|
err | ) |
err |
◆ CAST
#define CAST |
( |
|
type, |
|
|
|
new_var, |
|
|
|
var |
|
) |
| type new_var = dynamic_cast<type>(var) |
◆ cutil_check_error
#define cutil_check_error |
( |
|
err | ) |
err |
◆ cutil_safe_malloc
#define cutil_safe_malloc |
( |
|
mallocCall | ) |
(mallocCall) |
◆ DEBUG_TRACE
#define DEBUG_TRACE |
( |
|
fmt, |
|
|
|
args... |
|
) |
| fprintf(stderr, "[%s@%d]: " fmt "\n", __FILE__, __LINE__, ##args) |
◆ MAX
#define MAX |
( |
|
a, |
|
|
|
b |
|
) |
| ((a > b) ? a : b) |
◆ MIN
#define MIN |
( |
|
a, |
|
|
|
b |
|
) |
| ((a < b) ? a : b) |
◆ SCAST
#define SCAST |
( |
|
type, |
|
|
|
new_var, |
|
|
|
var |
|
) |
| type new_var = static_cast<type>(var) |
◆ __carma_check_msg()
void __carma_check_msg |
( |
const char * |
error_message, |
|
|
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 246 of file carma_utils.h.
248 cudaError_t
err = cudaGetLastError();
249 if (cudaSuccess != err) {
250 fprintf(stderr,
"(%s:%i) : carma_check_msg() CUTIL CUDA error : %s : %s.\n",
251 file, line, error_message, cudaGetErrorString(err));
252 throw cudaGetErrorString(err);
255 err = cudaDeviceSynchronize();
256 if (cudaSuccess != err) {
258 "(%s:%i) : carma_check_msg cudaDeviceSynchronize error: %s : %s.\n",
259 file, line, error_message, cudaGetErrorString(err));
260 throw cudaGetErrorString(err);
◆ __carma_safe_call()
void __carma_safe_call |
( |
cudaError |
err, |
|
|
const char * |
code, |
|
|
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 216 of file carma_utils.h.
218 if (cudaSuccess != err) {
219 fprintf(stderr,
"[%s:%i] %s\n carma_safe_call() Runtime API error : %s.\n",
220 file, line, code, cudaGetErrorString(err));
222 throw cudaGetErrorString(err);
◆ __carma_safe_call_no_sync()
void __carma_safe_call_no_sync |
( |
cudaError |
err, |
|
|
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 206 of file carma_utils.h.
208 if (cudaSuccess != err) {
209 fprintf(stderr,
"(%s:%i) : carma_safe_call_no_sync() Runtime API error : %s.\n",
210 file, line, cudaGetErrorString(err));
212 throw cudaGetErrorString(err);
◆ __carma_safe_device_synchronize()
void __carma_safe_device_synchronize |
( |
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 226 of file carma_utils.h.
227 cudaError
err = cudaDeviceSynchronize();
228 if (cudaSuccess != err) {
230 "(%s:%i) : cudaDeviceSynchronize() Driver API error : %s.\n", file,
231 line, cudaGetErrorString(err));
233 throw cudaGetErrorString(err);
◆ __carma_safe_malloc()
void __carma_safe_malloc |
( |
void * |
pointer, |
|
|
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 264 of file carma_utils.h.
266 fprintf(stderr,
"(%s:%i) : cutil_safe_malloc host malloc failure\n", file,
268 throw "cutil_safe_malloc() cutil_safe_malloc host malloc failure";
◆ __carmafft_safe_call()
void __carmafft_safe_call |
( |
cufftResult |
err, |
|
|
const char * |
file, |
|
|
const int |
line |
|
) |
| |
Definition at line 237 of file carma_utils.h.
239 if (CUFFT_SUCCESS != err) {
240 fprintf(stderr,
"(%s:%i) : carmafft_safe_call() CUFFT error.\n", file, line);
242 throw "carmafft_safe_call() CUFFT error";
◆ carma_start_profile()
void carma_start_profile |
( |
| ) |
|
◆ carma_stop_profile()
void carma_stop_profile |
( |
| ) |
|
◆ double_to_float()
int double_to_float |
( |
double * |
idata, |
|
|
float * |
odata, |
|
|
int |
N, |
|
|
CarmaDevice * |
device |
|
) |
| |
◆ fill_array_with_value()
template<typename T_data >
int fill_array_with_value |
( |
T_data * |
d_data, |
|
|
T_data |
value, |
|
|
int |
N, |
|
|
CarmaDevice * |
device |
|
) |
| |
◆ fill_sparse_vect()
template<class T_data >
int fill_sparse_vect |
( |
T_data * |
dense_data, |
|
|
int * |
colind_sorted, |
|
|
T_data * |
values, |
|
|
int * |
colind, |
|
|
int * |
rowind, |
|
|
int |
nnz, |
|
|
CarmaDevice * |
device |
|
) |
| |
◆ find_nnz()
template<class T_data >
int find_nnz |
( |
T_data * |
d_data, |
|
|
int * |
tmp_colind, |
|
|
int |
N, |
|
|
int * |
d_nnz, |
|
|
int & |
h_nnz, |
|
|
CarmaDevice * |
device |
|
) |
| |
◆ float_to_double()
int float_to_double |
( |
float * |
idata, |
|
|
double * |
odata, |
|
|
int |
N, |
|
|
CarmaDevice * |
device |
|
) |
| |
◆ get_num_blocks_and_threads()
void get_num_blocks_and_threads |
( |
CarmaDevice * |
device, |
|
|
int |
n, |
|
|
int & |
blocks, |
|
|
int & |
threads |
|
) |
| |
◆ is_pow2()
bool is_pow2 |
( |
unsigned int |
x | ) |
|
Definition at line 170 of file carma_utils.h.
170 {
return ((x & (x - 1)) == 0); }
◆ next_pow2()
unsigned int next_pow2 |
( |
unsigned int |
x | ) |
|
◆ print_mem_info()
◆ sum_get_num_blocks_and_threads()
void sum_get_num_blocks_and_threads |
( |
int |
n, |
|
|
CarmaDevice * |
device, |
|
|
int & |
blocks, |
|
|
int & |
threads |
|
) |
| |