-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathp3a_execution.cpp
71 lines (49 loc) · 1 KB
/
p3a_execution.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "p3a_execution.hpp"
namespace p3a {
#ifdef KOKKOS_ENABLE_CUDA
cuda_exception::cuda_exception(cudaError_t error)
:error_string(cudaGetErrorString(error))
{
}
const char* cuda_exception::what() const noexcept
{
return error_string.c_str();
}
namespace details {
void handle_cuda_error(cudaError_t error)
{
if (error == cudaSuccess) return;
throw cuda_exception(error);
}
}
namespace execution {
void cuda_policy::synchronize() const {
details::handle_cuda_error(
cudaStreamSynchronize(nullptr));
}
}
#endif
#ifdef KOKKOS_ENABLE_HIP
hip_exception::hip_exception(hipError_t error)
:error_string(hipGetErrorString(error))
{
}
const char* hip_exception::what() const noexcept
{
return error_string.c_str();
}
namespace details {
void handle_hip_error(hipError_t error)
{
if (error == hipSuccess) return;
throw hip_exception(error);
}
}
namespace execution {
void hip_policy::synchronize() const {
details::handle_hip_error(
hipStreamSynchronize(nullptr));
}
}
#endif
}