-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathCommon.h
54 lines (48 loc) · 1.04 KB
/
Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <Orochi/Orochi.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
inline
oroApi getApiType( int argc, char** argv )
{
// By default, the 2 API are enabled, and will be automatically selected by Orochi depending on the devices.
oroApi api = ( oroApi )( ORO_API_CUDA | ORO_API_HIP );
if( argc >= 2 )
{
if( strcmp( argv[1], "hip" ) == 0 )
api = ORO_API_HIP;
if( strcmp( argv[1], "cuda" ) == 0 )
api = ORO_API_CUDA;
}
return api;
}
// return true if error
inline bool checkError( oroError e )
{
if( e != oroSuccess )
{
const char* pStr = nullptr;
oroGetErrorString( e, &pStr );
printf("ERROR==================\n");
if ( pStr )
printf("%s\n", pStr);
else
printf("<No Error String>\n");
return true;
}
return false;
}
// return true if error
inline bool checkError( orortcResult e )
{
if ( e != ORORTC_SUCCESS )
{
printf("ERROR in RTC==================\n");
return true;
}
return false;
}
#define ERROR_CHECK( e ) if( checkError(e) ) testErrorFlag=true;