Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tbgl
tools
arbd
Commits
7fcd3c24
Commit
7fcd3c24
authored
6 months ago
by
cmaffeo2
Browse files
Options
Downloads
Patches
Plain Diff
Improve exception handling and logging on device code
parent
5217f4a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ARBDException.h
+20
-13
20 additions, 13 deletions
src/ARBDException.h
src/GPUManager.h
+1
-1
1 addition, 1 deletion
src/GPUManager.h
src/SignalManager.h
+16
-0
16 additions, 0 deletions
src/SignalManager.h
with
37 additions
and
14 deletions
src/ARBDException.h
+
20
−
13
View file @
7fcd3c24
...
...
@@ -11,15 +11,21 @@
#include
<exception>
#include
"SignalManager.h"
enum
ExceptionType
{
UnspeficiedError
,
NotImplementedError
,
ValueError
,
DivideByZeroError
,
CUDARuntimeError
,
FileIoError
,
FileOpenError
struct
ExceptionType
{
public:
explicit
constexpr
ExceptionType
(
int
value
)
noexcept
:
value
{
value
}
{};
constexpr
operator
int
()
const
{
return
value
;
};
private
:
const
int
value
;
};
// inline constexpr ExceptionType const UnspecifiedError{0};
constexpr
ExceptionType
const
UnspecifiedError
{
0
};
constexpr
ExceptionType
const
NotImplementedError
{
1
};
constexpr
ExceptionType
const
ValueError
{
2
};
constexpr
ExceptionType
const
DivideByZeroError
{
3
};
constexpr
ExceptionType
const
CUDARuntimeError
{
4
};
constexpr
ExceptionType
const
FileIoError
{
5
};
constexpr
ExceptionType
const
FileOpenError
{
6
};
class
_ARBDException
:
public
std
::
exception
{
...
...
@@ -29,7 +35,7 @@ class _ARBDException : public std::exception
std
::
string
sformat
(
const
std
::
string
&
fmt
,
va_list
&
ap
);
static
std
::
string
type_to_str
(
ExceptionType
type
)
{
switch
(
type
)
{
case
Unspe
fic
iedError
:
case
Unspe
cif
iedError
:
return
"Error"
;
case
NotImplementedError
:
return
"NotImplementedError"
;
...
...
@@ -44,11 +50,12 @@ class _ARBDException : public std::exception
};
// #include "common_macros.h"
#define S1(x) #x
#define S2(x) S1(x)
#define LOCATION __FILE__ "(" S2(__LINE__)")"
#ifdef CUDACC
#define Exception(...) throw _ARBDException(LOCATION, __VA_ARGS__)
#else
#define Exception(EXCPT,...) printf("Runtime CUDA exception at %s: ", LOCATION); \
printf("%s %s\n", #EXCPT, __VA_ARGS__);
#endif
//use illegal instruction to abort; used in functions defined both in __host__ and __device__
#if 0
#define CudaException(...) \
...
...
This diff is collapsed.
Click to expand it.
src/GPUManager.h
+
1
−
1
View file @
7fcd3c24
...
...
@@ -81,7 +81,7 @@ struct has_copy_to_cuda<T, decltype(std::declval<T>().copy_to_cuda(), void())> :
#ifndef gpuErrchk
#define delgpuErrchk
#define gpuErrchk(code) { if ((code) != cudaSuccess) { \
Exception(CUDARuntimeError,
" ",
cudaGetErrorString(code)); \
Exception(CUDARuntimeError, cudaGetErrorString(code)); \
}}
#endif
/*
...
...
This diff is collapsed.
Click to expand it.
src/SignalManager.h
+
16
−
0
View file @
7fcd3c24
...
...
@@ -11,7 +11,22 @@
/* #define ARBD_LOG_ACTIVE_LEVEL 0 */
/* #include "logger.h" */
#define S1(x) #x
#define S2(x) S1(x)
#define LOCATION __FILE__ "(" S2(__LINE__)")"
/* mainly used by ARBDException */
//*
#ifdef __CUDA_ARCH__
// #define LOGHELPER(TYPE, FMT,...) printf("[%d,%d] [%s] [%s]: %s", blockIdx.x, threadIdx.x, TYPE, LOCATION, FMT);
#define LOGHELPER(TYPE, FMT,...) printf("[%s] [%s]: %s\n", TYPE, LOCATION, FMT);
#define LOGTRACE(...) LOGHELPER("trace", __VA_ARGS__)
#define LOGDEBUG(...) LOGHELPER("debug",__VA_ARGS__)
// #define DEBUG(...) spdlog::debug(__VA_ARGS__)
#define LOGINFO(...) LOGHELPER("info",__VA_ARGS__)
#define LOGWARN(...) LOGHELPER("warn",__VA_ARGS__)
#define LOGERROR(...) LOGHELPER("error",__VA_ARGS__)
#define LOGCRITICAL(...) LOGHELPER("critical",__VA_ARGS__)
#else
#define FMT_HEADER_ONLY
#include
<spdlog/fmt/bundled/core.h>
#include
<spdlog/fmt/bundled/format.h>
...
...
@@ -29,6 +44,7 @@
#define LOGERROR(...) SPDLOG_ERROR(__VA_ARGS__)
#define LOGCRITICAL(...) SPDLOG_CRITICAL(__VA_ARGS__)
// spdlog::set_level(spdlog::level::trace);
#endif
//*/
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment