MAGMA
1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
testings.h
Go to the documentation of this file.
1
#ifndef _TESTINGS_H_
2
#define _TESTINGS_H_
3
4
#ifndef min
5
#define min(a,b) (((a)<(b))?(a):(b))
6
#endif
7
#ifndef max
8
#define max(a,b) (((a)<(b))?(b):(a))
9
#endif
10
11
#define TESTING_CUDA_INIT() \
12
CUdevice dev; \
13
CUcontext context; \
14
if( CUDA_SUCCESS != cuInit( 0 ) ) { \
15
fprintf(stderr, "CUDA: Not initialized\n" ); exit(-1); \
16
} \
17
if( CUDA_SUCCESS != cuDeviceGet( &dev, 0 ) ) { \
18
fprintf(stderr, "CUDA: Cannot get the device\n"); exit(-1); \
19
} \
20
if( CUDA_SUCCESS != cuCtxCreate( &context, 0, dev ) ) { \
21
fprintf(stderr, "CUDA: Cannot create the context\n"); exit(-1); \
22
} \
23
if( CUBLAS_STATUS_SUCCESS != cublasInit( ) ) { \
24
fprintf(stderr, "CUBLAS: Not initialized\n"); exit(-1); \
25
} \
26
printout_devices( );
27
28
29
#define TESTING_CUDA_FINALIZE() \
30
cuCtxDetach( context ); \
31
cublasShutdown();
32
33
34
#define TESTING_MALLOC(__ptr, __type, __size) \
35
__ptr = (__type*)malloc((__size) * sizeof(__type)); \
36
if (__ptr == 0) { \
37
fprintf (stderr, "!!!! Malloc failed for: %s\n", #__ptr ); \
38
exit(-1); \
39
}
40
41
#define TESTING_HOSTALLOC(__ptr, __type, __size) \
42
if( cudaSuccess != cudaMallocHost( (void**)&__ptr, (__size)*sizeof(__type) ) ) { \
43
fprintf (stderr, "!!!! cudaMallocHost failed for: %s\n", #__ptr ); \
44
exit(-1); \
45
}
46
47
#define TESTING_DEVALLOC(__ptr, __type, __size) \
48
if( cudaSuccess != cudaMalloc( (void**)&__ptr, (__size)*sizeof(__type) ) ){ \
49
fprintf (stderr, "!!!! cublasAlloc failed for: %s\n", #__ptr ); \
50
exit(-1); \
51
}
52
53
54
#define TESTING_FREE(__ptr) \
55
free(__ptr);
56
57
#define TESTING_HOSTFREE(__ptr) \
58
cudaFreeHost( __ptr );
59
60
#define TESTING_DEVFREE(__ptr) \
61
cudaFree( __ptr );
62
63
#endif
/* _TESTINGS_H_ */
magma-1.2.0
exp
testing
testings.h
Generated on Mon May 21 2012 16:42:20 for MAGMA by
1.8.1