-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2927 from psychocoderHPC/topic-pmaccTypesCleanup
cleanup `pmacc/types.hpp`
- Loading branch information
Showing
14 changed files
with
581 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* Copyright 2013-2019 Felix Schmitt, Heiko Burau, Rene Widera, | ||
* Wolfgang Hoenig, Benjamin Worpitz, | ||
* Alexander Grund | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
/** | ||
* Visual Studio has a bug with constexpr variables being captured in lambdas as | ||
* non-constexpr variables, causing build errors. The issue has been verified | ||
* for versions 14.0 and 15.5 (latest at the moment) and is also reported in | ||
* https://stackoverflow.com/questions/28763375/using-lambda-captured-constexpr-value-as-an-array-dimension | ||
* and related issue | ||
* https://developercommunity.visualstudio.com/content/problem/1997/constexpr-not-implicitely-captured-in-lambdas.html | ||
* | ||
* As a workaround (until this is fixed in VS) add a new PMACC_CONSTEXPR_CAPTURE | ||
* macro for declaring constexpr variables that are captured in lambdas and have | ||
* to remain constexpr inside a lambda e.g., used as a template argument. Such | ||
* variables have to be declared with PMACC_CONSTEXPR_CAPTURE instead of | ||
* constexpr. The macro will be replaced with just constexpr for other compilers | ||
* and for Visual Studio with static constexpr, which makes it capture properly. | ||
* | ||
* Note that this macro is to be used only in very few cases, where not only a | ||
* constexpr is captured, but also it has to remain constexpr inside a lambda. | ||
*/ | ||
#ifdef _MSC_VER | ||
# define PMACC_CONSTEXPR_CAPTURE static constexpr | ||
#else | ||
# define PMACC_CONSTEXPR_CAPTURE constexpr | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Copyright 2013-2019 Felix Schmitt, Heiko Burau, Rene Widera, | ||
* Wolfgang Hoenig, Benjamin Worpitz, | ||
* Alexander Grund | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// compatibility macros (compiler or C++ standard version specific) | ||
#include <boost/config.hpp> | ||
// work-around for Boost 1.68.0 | ||
// fixed in https://github.com/boostorg/predef/pull/84 | ||
// see https://github.com/ComputationalRadiationPhysics/alpaka/pull/606 | ||
// include <boost/predef.h> | ||
#include <alpaka/core/BoostPredef.hpp> | ||
|
||
|
||
/** C++11 and C++14 explicit fallthrough in switch cases | ||
* | ||
* Use [[fallthrough]] in C++17 | ||
*/ | ||
#if (BOOST_COMP_GNUC >= BOOST_VERSION_NUMBER(7,0,0)) | ||
# define PMACC_FALLTHROUGH [[gnu::fallthrough]] | ||
#elif BOOST_COMP_CLANG | ||
# define PMACC_FALLTHROUGH [[clang::fallthrough]] | ||
#else | ||
# define PMACC_FALLTHROUGH ( (void)0 ) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* Copyright 2013-2019 Felix Schmitt, Heiko Burau, Rene Widera, | ||
* Wolfgang Hoenig, Benjamin Worpitz, | ||
* Alexander Grund | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cupla/types.hpp> | ||
|
||
|
||
#define HDINLINE ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE | ||
#define DINLINE ALPAKA_FN_ACC ALPAKA_FN_INLINE | ||
#define DEVICEONLY ALPAKA_FN_ACC | ||
#define HINLINE ALPAKA_FN_HOST ALPAKA_FN_INLINE | ||
|
||
/** | ||
* CUDA architecture version (aka PTX ISA level) | ||
* 0 for host compilation | ||
*/ | ||
#ifndef __CUDA_ARCH__ | ||
# define PMACC_CUDA_ARCH 0 | ||
#else | ||
# define PMACC_CUDA_ARCH __CUDA_ARCH__ | ||
#endif | ||
|
||
/** PMacc global identifier for CUDA kernel */ | ||
#define PMACC_GLOBAL_KEYWORD DINLINE | ||
|
||
/* | ||
* Disable nvcc warning: | ||
* calling a __host__ function from __host__ __device__ function. | ||
* | ||
* Usage: | ||
* PMACC_NO_NVCC_HDWARNING | ||
* HDINLINE function_declaration() | ||
* | ||
* It is not possible to disable the warning for a __host__ function | ||
* if there are calls of virtual functions inside. For this case use a wrapper | ||
* function. | ||
* WARNING: only use this method if there is no other way to create runable code. | ||
* Most cases can solved by #ifdef __CUDA_ARCH__ or #ifdef __CUDACC__. | ||
*/ | ||
#if defined(__CUDACC__) | ||
# define PMACC_NO_NVCC_HDWARNING _Pragma("hd_warning_disable") | ||
#else | ||
# define PMACC_NO_NVCC_HDWARNING | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Copyright 2013-2019 Felix Schmitt, Heiko Burau, Rene Widera, | ||
* Wolfgang Hoenig, Benjamin Worpitz, | ||
* Alexander Grund | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cuda_to_cupla.hpp> | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
namespace pmacc | ||
{ | ||
|
||
/** | ||
* Print a cuda error message including file/line info to stderr | ||
*/ | ||
#define PMACC_PRINT_CUDA_ERROR(msg) \ | ||
std::cerr << "[CUDA] Error: <" << __FILE__ << ">:" << __LINE__ << " " << msg << std::endl | ||
|
||
/** | ||
* Print a cuda error message including file/line info to stderr and raises an exception | ||
*/ | ||
#define PMACC_PRINT_CUDA_ERROR_AND_THROW(cudaError, msg) \ | ||
PMACC_PRINT_CUDA_ERROR(msg); \ | ||
throw std::runtime_error(std::string("[CUDA] Error: ") + std::string(cudaGetErrorString(cudaError))) | ||
|
||
/** | ||
* Captures CUDA errors and prints messages to stdout, including line number and file. | ||
* | ||
* @param cmd command with cudaError_t return value to check | ||
*/ | ||
#define CUDA_CHECK(cmd) {cudaError_t error = cmd; if(error!=cudaSuccess){ PMACC_PRINT_CUDA_ERROR_AND_THROW(error, ""); }} | ||
|
||
#define CUDA_CHECK_MSG(cmd,msg) {cudaError_t error = cmd; if(error!=cudaSuccess){ PMACC_PRINT_CUDA_ERROR_AND_THROW(error, msg); }} | ||
|
||
#define CUDA_CHECK_NO_EXCEPT(cmd) {cudaError_t error = cmd; if(error!=cudaSuccess){ PMACC_PRINT_CUDA_ERROR(""); }} | ||
|
||
} // namespace pmacc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright 2019 Rene Widera | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
//! Defines number of dimensions (1-3) | ||
#define DIM1 1u | ||
#define DIM2 2u | ||
#define DIM3 3u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright 2013-2019 Felix Schmitt, Heiko Burau, Rene Widera, | ||
* Wolfgang Hoenig, Benjamin Worpitz, | ||
* Alexander Grund | ||
* | ||
* This file is part of PMacc. | ||
* | ||
* PMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PMacc is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with PMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
|
||
namespace pmacc | ||
{ | ||
namespace eventSystem | ||
{ | ||
|
||
/** | ||
* Internal event/task type used for notifications in the event system. | ||
*/ | ||
enum EventType | ||
{ | ||
FINISHED, | ||
COPYHOST2DEVICE, | ||
COPYDEVICE2HOST, | ||
COPYDEVICE2DEVICE, | ||
SENDFINISHED, | ||
RECVFINISHED, | ||
LOGICALAND, | ||
SETVALUE, | ||
GETVALUE, | ||
KERNEL | ||
}; | ||
|
||
} // namespace type | ||
|
||
// for backward compatibility pull all definitions into the pmacc namespace | ||
using namespace eventSystem; | ||
} // namespace pmacc |
Oops, something went wrong.