Geant4
11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
LUPI_declareMacro.hpp
Go to the documentation of this file.
1
/*
2
# <<BEGIN-copyright>>
3
# Copyright 2019, Lawrence Livermore National Security, LLC.
4
# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5
# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6
# SPDX-License-Identifier: MIT
7
# <<END-copyright>>
8
*/
9
10
#ifndef LUPI_declare_macro_hpp_included
11
#define LUPI_declare_macro_hpp_included
12
13
#include <
LUPI_defines.hpp
>
14
15
// Default, if LUPI_HIP_INLINE is not defined, is to use an attribute function
16
// to inform HIP not to inline the function.
17
// This is quite useful for the publicly installed header files for code robustness
18
// However, when compiling the source, one should be able to disable
19
// this within the library itself for faster code. To do so
20
// the define -DLUPI_HIP_INLINE can be added to the compiler flags, and
21
// the define will evaluate to nothing, so the compiler is welcome to do
22
// its optimizations.
23
24
#ifdef LUPI_HIP_INLINE
25
#define LUPI_HIP_INLINE_ATTRIBUTE
26
#else
27
#define LUPI_HIP_INLINE_ATTRIBUTE __attribute__ ((noinline))
28
#endif
29
30
#define gpuErrorCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
31
32
#if defined(__HIP_DEVICE_COMPILE__) || defined(__CUDA_ARCH__)
33
#define LUPI_ON_GPU 1
34
#endif
35
36
#ifdef __CUDACC__
37
#include <cstdio>
38
#define LUPI_HOST __host__
39
#define LUPI_DEVICE __device__
40
#define LUPI_HOST_DEVICE __host__ __device__
41
#define LUPI_THROW(arg) printf("%s", arg)
42
#define LUPI_WARP_SIZE 32
43
#define LUPI_THREADID threadIdx.x
44
inline
void
gpuAssert
(cudaError_t
code
,
const
char
*file,
int
line,
bool
abort=
true
)
45
{
46
if
(
code
!= cudaSuccess)
47
{
48
fprintf(stderr,
"GPUASSERT: %s File: %s line: %d\n"
, cudaGetErrorString(
code
), file, line);
49
if
(abort) exit(
code
);
50
}
51
}
52
53
#elif HAVE_OPENMP_TARGET
54
#define LUPI_HOST
55
#define LUPI_DEVICE
56
#define LUPI_HOST_DEVICE
57
#define LUPI_THROW(arg) printf("%s", arg)
58
#define LUPI_WARP_SIZE 1
59
#define LUPI_THREADID
60
inline
void
gpuAssert
(
int
code
,
const
char
*file,
int
line,
bool
abort=
true
) {}
61
#elif defined(__HIP__)
62
#include <hip/hip_version.h>
63
#include <hip/hip_runtime.h>
64
#include <hip/hip_runtime_api.h>
65
#include <hip/hip_common.h>
66
67
#define LUPI_HOST __host__
68
#define LUPI_DEVICE __device__
69
#define LUPI_HOST_DEVICE LUPI_HIP_INLINE_ATTRIBUTE __host__ __device__
70
#define LUPI_THROW(arg)
71
#define LUPI_WARP_SIZE 1
72
#define LUPI_THREADID hipThreadIdx_x
73
inline
void
gpuAssert
(hipError_t
code
,
const
char
*file,
int
line,
bool
do_abort=
true
)
74
{
75
if
(
code
== hipSuccess) {
return
; }
76
printf(
"GPUassert code %d: %s %s %d\n"
,
code
, hipGetErrorString(
code
), file, line);
77
if
(do_abort) { abort(); }
78
}
79
80
#else
81
#define LUPI_HOST
82
#define LUPI_DEVICE
83
#define LUPI_HOST_DEVICE
84
#define LUPI_THROW(arg) throw arg
85
#define LUPI_WARP_SIZE 1
86
#define LUPI_THREADID
87
inline
void
gpuAssert
(
LUPI_maybeUnused
int
code
,
LUPI_maybeUnused
const
char
*file,
LUPI_maybeUnused
int
line,
LUPI_maybeUnused
bool
abort=
true
) {}
88
#endif
89
90
#endif
// End of LUPI_declare_macro_hpp_included
gpuAssert
void gpuAssert(LUPI_maybeUnused int code, LUPI_maybeUnused const char *file, LUPI_maybeUnused int line, LUPI_maybeUnused bool abort=true)
Definition
LUPI_declareMacro.hpp:87
LUPI_defines.hpp
LUPI_maybeUnused
#define LUPI_maybeUnused
Definition
LUPI_defines.hpp:16
code
Definition
inftrees.h:24
geant4-v11.4.0
source
processes
hadronic
models
lend
include
LUPI_declareMacro.hpp
Generated by
1.16.1