2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2020,2021, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \libinternal \file
37 * Wraps the complexity of including SYCL in GROMACS.
39 * The __SYCL_COMPILER_VERSION macro is used to identify Intel DPCPP compiler.
40 * See https://github.com/intel/llvm/pull/2998 for better proposal.
42 * Intel SYCL headers use symbol DIM as a template parameter, which gets broken by macro DIM defined
43 * in gromacs/math/vectypes.h. Here, we include the SYCL header while temporary undefining this macro.
44 * See https://github.com/intel/llvm/issues/2981.
46 * Different compilers, at the time of writing, have different names for some of the proposed features
47 * of the SYCL2020 standard. For uniformity, they are all aliased in our custom sycl_2020 namespace.
52 #ifndef GMX_GPU_UTILS_GMXSYCL_H
53 #define GMX_GPU_UTILS_GMXSYCL_H
57 /* Some versions of Intel ICPX compiler (at least 2021.1.1 and 2021.1.2) fail to unroll a loop
58 * in sycl::accessor::__init, and emit -Wpass-failed=transform-warning. This is a useful
59 * warning, but mostly noise right now. Probably related to using shared memory accessors.
60 * The unroll directive was introduced in https://github.com/intel/llvm/pull/2449. */
62 # include <CL/sycl/version.hpp>
63 # define DISABLE_UNROLL_WARNINGS \
64 ((__SYCL_COMPILER_VERSION >= 20201113) && (__SYCL_COMPILER_VERSION <= 20201214))
66 # define DISABLE_UNROLL_WARNINGS 0
69 #if DISABLE_UNROLL_WARNINGS
70 # pragma clang diagnostic push
71 # pragma clang diagnostic ignored "-Wpass-failed"
74 // For hipSYCL, we need to activate floating-point atomics
76 # define HIPSYCL_EXT_FP_ATOMICS
77 # pragma clang diagnostic push
78 # pragma clang diagnostic ignored "-Wunused-variable"
79 # pragma clang diagnostic ignored "-Wunused-parameter"
80 # pragma clang diagnostic ignored "-Wmissing-noreturn"
81 # pragma clang diagnostic ignored "-Wshadow-field"
82 # pragma clang diagnostic ignored "-Wctad-maybe-unsupported"
83 # pragma clang diagnostic ignored "-Wdeprecated-copy-dtor"
84 # pragma clang diagnostic ignored "-Winconsistent-missing-destructor-override"
85 # pragma clang diagnostic ignored "-Wunused-template"
86 # pragma clang diagnostic ignored "-Wsign-compare"
87 # pragma clang diagnostic ignored "-Wundefined-reinterpret-cast"
88 # pragma clang diagnostic ignored "-Wdeprecated-copy"
89 # pragma clang diagnostic ignored "-Wnewline-eof"
90 # pragma clang diagnostic ignored "-Wextra-semi"
91 # pragma clang diagnostic ignored "-Wsuggest-override"
92 # pragma clang diagnostic ignored "-Wsuggest-destructor-override"
93 # pragma clang diagnostic ignored "-Wgcc-compat"
99 # error "The workaround here assumes we use DIM=3."
102 # include <CL/sycl.hpp>
106 # include <CL/sycl.hpp>
109 #if DISABLE_UNROLL_WARNINGS
110 # pragma clang diagnostic pop
114 # pragma clang diagnostic pop
117 #undef DISABLE_UNROLL_WARNINGS
119 /* Exposing Intel-specific extensions in a manner compatible with SYCL2020 provisional spec.
120 * Despite ICPX (up to 2021.1.2 at the least) having SYCL_LANGUAGE_VERSION=202001,
121 * some parts of the spec are still in custom sycl::ONEAPI namespace (sycl::intel in beta versions),
122 * and some functions have different names. To make things easier to upgrade
123 * in the future, this thin layer is added.
130 // Confirmed to work for 2021.1-beta10 (20201005), 2021.1.1 (20201113), 2021.1.2 (20201214).
131 namespace origin = cl::sycl::ONEAPI;
132 #elif GMX_SYCL_HIPSYCL
133 namespace origin = cl::sycl;
135 # error "Unsupported version of SYCL compiler"
137 } // namespace detail
139 using detail::origin::memory_order;
140 using detail::origin::memory_scope;
141 using detail::origin::plus;
142 using detail::origin::sub_group;
145 using detail::origin::atomic_ref;
146 template<typename... Args>
147 bool group_any_of(Args&&... args)
149 return detail::origin::any_of(std::forward<Args>(args)...);
151 template<typename... Args>
152 auto group_reduce(Args&&... args) -> decltype(detail::origin::reduce(std::forward<Args>(args)...))
154 return detail::origin::reduce(std::forward<Args>(args)...);
156 #elif GMX_SYCL_HIPSYCL
157 // No atomic_ref in hipSYCL yet (2021-02-22)
158 using detail::origin::group_any_of;
159 using detail::origin::group_reduce;
161 # error "Unsupported SYCL compiler"
164 } // namespace sycl_2020