https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosHeader.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://www.mooseframework.org
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#ifndef MOOSE_KOKKOS_SCOPE
13#error Kokkos header was included in a source file which is not in the Kokkos compilation scope
14#endif
15
16// NVCC invokes compile error due to conflicting built-in and PETSc complex operators
17// so this preprocessor should be defined
18#define PETSC_SKIP_CXX_COMPLEX_FIX 1
19
20// Kokkos headers
21#include "Kokkos_Core.hpp"
22#include "Kokkos_StdAlgorithms.hpp"
23
24// libMesh uses an old Boost library and causes a build error due to an outdated CUDA
25// preprocessor which should be manually undefined after including CUDA runtime header
26#undef __CUDACC_VER__
27
28// MOOSE includes
29#include "MooseError.h"
30#include "MooseUtils.h"
31#include "MooseConfig.h"
32
33// Architecture-dependent execution spaces
34#ifdef MOOSE_ENABLE_KOKKOS_GPU
35#ifdef KOKKOS_ENABLE_CUDA
36#define MemSpace ::Kokkos::CudaSpace
37#define ExecSpace ::Kokkos::Cuda
38#define KOKKOS_VIRTUAL virtual
39#define KOKKOS_OVERRIDE override
40#endif
41#ifdef KOKKOS_ENABLE_HIP
42#define MemSpace ::Kokkos::HIPSpace
43#define ExecSpace ::Kokkos::HIP
44#define KOKKOS_VIRTUAL virtual
45#define KOKKOS_OVERRIDE override
46#endif
47#ifdef KOKKOS_ENABLE_SYCL
48#define MemSpace ::Kokkos::SYCLDeviceUSMSpace
49#define ExecSpace ::Kokkos::SYCL
50#define KOKKOS_VIRTUAL
51#define KOKKOS_OVERRIDE
52#endif
53#else
54#define MemSpace ::Kokkos::HostSpace
55#define ExecSpace ::Kokkos::OpenMP
56#undef KOKKOS_FUNCTION
57#define KOKKOS_FUNCTION
58#undef KOKKOS_INLINE_FUNCTION
59#define KOKKOS_INLINE_FUNCTION inline
60#define KOKKOS_VIRTUAL virtual
61#define KOKKOS_OVERRIDE override
62#undef KOKKOS_IF_ON_HOST
63#define KOKKOS_IF_ON_HOST(code) \
64 if (!omp_get_level()) \
65 { \
66 code \
67 }
68#undef KOKKOS_IF_ON_DEVICE
69#define KOKKOS_IF_ON_DEVICE(code) \
70 if (omp_get_level()) \
71 { \
72 code \
73 }
74#endif
75
76namespace Moose::Kokkos
77{
81constexpr unsigned int MAX_TAG = 30;
85constexpr unsigned int MAX_CACHED_DOF = 30;
86} // namespace Moose::Kokkos
constexpr unsigned int MAX_CACHED_DOF
Maximum number of DOFs to cache during residual and Jacobian computation.
constexpr unsigned int MAX_TAG
Maximum tag ID.