SIRIUS 7.5.0
Electronic structure library and applications
acc_runtime.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file acc_runtime.hpp
21 *
22 * \brief Uniform interface to the runtime API of CUDA and ROCm.
23 *
24 */
25#ifndef __ACC_RUNTIME_HPP__
26#define __ACC_RUNTIME_HPP__
27
28#include "acc.hpp"
29
30#if defined(SIRIUS_CUDA)
31#include <cuda_runtime.h>
32#endif
33
34#if defined(SIRIUS_ROCM)
35#include <hip/hip_runtime.h>
36#endif
37
38/*
39 * CUDA runtime calls and definitions
40 */
41#ifdef SIRIUS_CUDA
42#define accLaunchKernel(kernelName, numblocks, numthreads, memperblock, streamId, ...) \
43 do { \
44 kernelName<<<numblocks, numthreads, memperblock, streamId>>>(__VA_ARGS__); \
45 } while (0)
46
47#define hipThreadIdx_x threadIdx.x
48#define hipThreadIdx_y threadIdx.y
49#define hipThreadIdx_z threadIdx.z
50
51#define hipBlockIdx_x blockIdx.x
52#define hipBlockIdx_y blockIdx.y
53#define hipBlockIdx_z blockIdx.z
54
55#define hipBlockDim_x blockDim.x
56#define hipBlockDim_y blockDim.y
57#define hipBlockDim_z blockDim.z
58
59#define hipGridDim_x gridDim.x
60#define hipGridDim_y gridDim.y
61#define hipGridDim_z gridDim.z
62#endif
63
64/*
65 * ROCM runtime calls and definitions
66 */
67#ifdef SIRIUS_ROCM
68#define accLaunchKernel(...) \
69 do { \
70 hipLaunchKernelGGL(__VA_ARGS__); \
71 } while (0)
72
73#endif
74
75#endif
Interface to accelerators API.