Fix random typos
[alexxy/gromacs.git] / src / gromacs / gpu_utils / gpu_macros.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2014,2015,2017,2018,2019, by the GROMACS development team.
5  * Copyright (c) 2020,2021, by the GROMACS development team, led by
6  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7  * and including many others, as listed in the AUTHORS file in the
8  * top-level source directory and at http://www.gromacs.org.
9  *
10  * GROMACS is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * GROMACS is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with GROMACS; if not, see
22  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24  *
25  * If you want to redistribute modifications to GROMACS, please
26  * consider that scientific software is very special. Version
27  * control is crucial - bugs must be traceable. We will be happy to
28  * consider code for inclusion in the official distribution, but
29  * derived work must not be called official GROMACS. Details are found
30  * in the README & COPYING files - if they are missing, get the
31  * official version at http://www.gromacs.org.
32  *
33  * To help us fund GROMACS development, we humbly ask that you cite
34  * the research papers on the package. Check out http://www.gromacs.org.
35  */
36 #ifndef GMX_GPU_UTILS_MACROS_H
37 #define GMX_GPU_UTILS_MACROS_H
38
39 #include "config.h"
40
41 #include "gromacs/utility/basedefinitions.h" // for gmx_unused
42
43 /* These macros that let us define inlineable null implementations so
44    that non-GPU Gromacs can run with no overhead without conditionality
45    everywhere a GPU function is called. */
46 #define REAL_FUNC_QUALIFIER
47 #define REAL_FUNC_ARGUMENT(arg) arg
48 #define REAL_FUNC_TERM
49 #define REAL_FUNC_TERM_WITH_RETURN(arg)
50
51 #define NULL_FUNC_QUALIFIER gmx_unused static
52 #define NULL_FUNC_ARGUMENT(arg) arg gmx_unused
53 #define NULL_FUNC_TERM \
54     {                  \
55     }
56 #define NULL_FUNC_TERM_WITH_RETURN(arg) \
57     {                                   \
58         return (arg);                   \
59     }
60
61 #ifdef DOXYGEN
62
63 /* Doxygen build appreciates always having argument names, and doesn't
64  * care about duplicate function definitions. */
65 #    define GPU_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
66 #    define GPU_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
67 #    define GPU_FUNC_TERM REAL_FUNC_TERM
68 #    define GPU_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
69 #    define CUDA_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
70 #    define CUDA_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
71 #    define CUDA_FUNC_TERM REAL_FUNC_TERM
72 #    define CUDA_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
73 #    define OPENCL_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
74 #    define OPENCL_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
75 #    define OPENCL_FUNC_TERM REAL_FUNC_TERM
76 #    define OPENCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
77 #    define SYCL_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
78 #    define SYCL_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
79 #    define SYCL_FUNC_TERM REAL_FUNC_TERM
80 #    define SYCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
81
82 #else // Not DOXYGEN
83
84 /* GPU support is enabled, so these functions will have real code defined somewhere */
85 #    if GMX_GPU
86 #        define GPU_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
87 #        define GPU_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
88 #        define GPU_FUNC_TERM REAL_FUNC_TERM
89 #        define GPU_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
90 #    else
91 #        define GPU_FUNC_QUALIFIER NULL_FUNC_QUALIFIER
92 #        define GPU_FUNC_ARGUMENT NULL_FUNC_ARGUMENT
93 #        define GPU_FUNC_TERM NULL_FUNC_TERM
94 #        define GPU_FUNC_TERM_WITH_RETURN(arg) NULL_FUNC_TERM_WITH_RETURN(arg)
95 #    endif
96
97 /* Enable and disable platform-specific function implementations */
98 #    if GMX_GPU_OPENCL
99 #        define OPENCL_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
100 #        define OPENCL_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
101 #        define OPENCL_FUNC_TERM REAL_FUNC_TERM
102 #        define OPENCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
103 #    else
104 #        define OPENCL_FUNC_QUALIFIER NULL_FUNC_QUALIFIER
105 #        define OPENCL_FUNC_ARGUMENT NULL_FUNC_ARGUMENT
106 #        define OPENCL_FUNC_TERM NULL_FUNC_TERM
107 #        define OPENCL_FUNC_TERM_WITH_RETURN(arg) NULL_FUNC_TERM_WITH_RETURN(arg)
108 #    endif
109
110 #    if GMX_GPU_CUDA
111 #        define CUDA_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
112 #        define CUDA_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
113 #        define CUDA_FUNC_TERM REAL_FUNC_TERM
114 #        define CUDA_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
115 #    else
116 #        define CUDA_FUNC_QUALIFIER NULL_FUNC_QUALIFIER
117 #        define CUDA_FUNC_ARGUMENT NULL_FUNC_ARGUMENT
118 #        define CUDA_FUNC_TERM NULL_FUNC_TERM
119 #        define CUDA_FUNC_TERM_WITH_RETURN(arg) NULL_FUNC_TERM_WITH_RETURN(arg)
120 #    endif
121
122 #    if GMX_GPU_SYCL
123 #        define SYCL_FUNC_QUALIFIER REAL_FUNC_QUALIFIER
124 #        define SYCL_FUNC_ARGUMENT REAL_FUNC_ARGUMENT
125 #        define SYCL_FUNC_TERM REAL_FUNC_TERM
126 #        define SYCL_FUNC_TERM_WITH_RETURN(arg) REAL_FUNC_TERM_WITH_RETURN(arg)
127 #    else
128 #        define SYCL_FUNC_QUALIFIER NULL_FUNC_QUALIFIER
129 #        define SYCL_FUNC_ARGUMENT NULL_FUNC_ARGUMENT
130 #        define SYCL_FUNC_TERM NULL_FUNC_TERM
131 #        define SYCL_FUNC_TERM_WITH_RETURN(arg) NULL_FUNC_TERM_WITH_RETURN(arg)
132 #    endif
133
134 #endif // ifdef DOXYGEN
135
136 #endif // GMX_GPU_UTILS_MACROS_H