Files
rocm-systems/rocclr/runtime/utils/macros.hpp
T
foreman b33c52ed6f P4 to Git Change 1591041 by vsytchen@vsytchen-win10 on 2018/08/08 18:46:17
SWDEV-159881 - [OCL][ROCm] Add SVM coarse-grain buffer support with device memory (Part 1)

	1. Implement submitSvmFree/Copy/FillMemory.
	2. Add macro IS_HIP that determines if the client is HIP.
	3. Add setting enableCoarseGrainSVM that allows the use of device memory for coarse grain SVM allocations.
	4. Set enableCoarseGrainSVM to be true only for HIP.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/15597/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#93 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#35 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#15 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#61 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#294 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/macros.hpp#10 edit
2018-08-08 18:58:03 -04:00

194 rivejä
4.2 KiB
C++

//
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef MACROS_HPP_
#define MACROS_HPP_
#ifndef OPENCL_EXPORTS
#define OPENCL_EXPORTS 1
#endif // OPENCL_EXPORTS
#if defined(NDEBUG)
#define RELEASE 1
#else // !NDEBUG
#define ASSERT 1
#define DEBUG 1
#endif // !NDEBUG
#if defined(_WIN64) && !defined(_LP64)
#define _LP64 1
#endif
#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG 1
#endif // _DEBUG && !DEBUG
#if defined(DEBUG) && defined(RELEASE)
#error "Build Error: cannot have both -DDEBUG and -DRELEASE"
#endif /*DEBUG && RELEASE*/
#if !defined(DEBUG) && !defined(RELEASE)
#error "Build Error: must have either -DDEBUG or -DRELEASE"
#endif /*DEBUG && RELEASE*/
#ifdef DEBUG
#define DEBUG_ONLY(x) x
#define RELEASE_ONLY(x)
#define IS_DEBUG true
#else // !DEBUG
#define DEBUG_ONLY(x)
#define RELEASE_ONLY(x) x
#define IS_DEBUG false
#endif /*!DEBUG*/
#define DEBUG_SWITCH(d, r) DEBUG_ONLY(d) RELEASE_ONLY(r)
#define RELEASE_SWITCH(r, d) RELEASE_ONLY(r) DEBUG_ONLY(d)
//! \brief Make a c-string of __macro__
#define STR(__macro__) #__macro__
//! \brief Make a c-string of the expansion of __macro__
#define XSTR(__macro__) STR(__macro__)
//! \brief Concatenate 2 symbols
#define CONCAT(a, b) a##b
#define XCONCAT(a, b) CONCAT(a, b)
//! \cond ignore
#ifdef _LP64
#define LP64_ONLY(x) x
#define NOT_LP64(x)
#else // !_LP64
#define LP64_ONLY(x)
#define NOT_LP64(x) x
#endif /*!_LP64*/
#define LP64_SWITCH(lp32, lp64) NOT_LP64(lp32) LP64_ONLY(lp64)
#ifdef __linux__
#define IS_LINUX true
#define LINUX_ONLY(x) x
#define NOT_LINUX(x)
#else // !__linux__
#define LINUX_ONLY(x)
#define NOT_LINUX(x) x
#endif /*!__linux__*/
#ifdef __APPLE__
#define IS_MACOS true
#define MACOS_ONLY(x) x
#define NOT_MACOS(x)
#else // !__APPLE__
#define MACOS_ONLY(x)
#define NOT_MACOS(x) x
#endif /*!__APPLE__*/
#ifdef _WIN32
#define IS_WINDOWS true
#define WINDOWS_ONLY(x) x
#define NOT_WINDOWS(x)
#else // !_WIN32
#define WINDOWS_ONLY(x)
#define NOT_WINDOWS(x) x
#endif /*!_WIN32*/
#ifdef _WIN64
#define WIN64_ONLY(x) x
#define NOT_WIN64(x)
#else // !_WIN64
#define WIN64_ONLY(x)
#define NOT_WIN64(x) x
#endif /*!_WIN64*/
#ifdef WITH_LIGHTNING_COMPILER
#define LIGHTNING_ONLY(x) x
#define NOT_LIGHTNING(x)
#define IS_LIGHTNING true
#else /* !WITH_LIGHTNING_COMPILER */
#define LIGHTNING_ONLY(x)
#define NOT_LIGHTNING(x) x
#endif /* !WITH_LIGHTNING_COMPILER */
#ifdef BUILD_HIP
#define IS_HIP true
#endif
#ifndef IS_LINUX
#define IS_LINUX false
#endif
#ifndef IS_MACOS
#define IS_MACOS false
#endif
#ifndef IS_WINDOWS
#define IS_WINDOWS false
#endif
#ifndef IS_LIGHTNING
#define IS_LIGHTNING false
#endif
#ifndef IS_HIP
#define IS_HIP false
#endif
#define IF_LEFT_true(x) x
#define IF_LEFT_false(x)
#define IF_RIGHT_true(x)
#define IF_RIGHT_false(x) x
#define IF_LEFT(cond, x) IF_LEFT_##cond(x)
#define IF_RIGHT(cond, x) IF_RIGHT_##cond(x)
#define IF(cond, x, y) IF_LEFT(cond, x) IF_RIGHT(cond, y)
#define LIGHTNING_SWITCH(x, other) LIGHTNING_ONLY(x) NOT_LIGHTNING(other)
#define LINUX_SWITCH(x, other) LINUX_ONLY(x) NOT_LINUX(other)
#define MACOS_SWITCH(x, other) MACOS_ONLY(x) NOT_MACOS(other)
#define WINDOWS_SWITCH(x, other) WINDOWS_ONLY(x) NOT_WINDOWS(other)
#define IS_MAINLINE true
#ifdef OPTIMIZED
#define OPTIMIZED_ONLY(x) x
#define NOT_OPTIMIZED(x)
#define IS_OPTIMIZED true
#else
#define OPTIMIZED_ONLY(x)
#define NOT_OPTIMIZED(x) x
#define IS_OPTIMIZED false
#endif
#if defined(__GNUC__)
#define __ALIGNED__(x) __attribute__((aligned(x)))
#elif defined(_MSC_VER)
#define __ALIGNED__(x) __declspec(align(x))
#elif defined(RC_INVOKED)
#define __ALIGNED__(x)
#else
#error
#endif /*_MSC_VER*/
#if defined(__GNUC__)
#define likely(cond) __builtin_expect(!!(cond), 1)
#define unlikely(cond) __builtin_expect(!!(cond), 0)
#else // !__GNUC__
#define likely(cond) (cond)
#define unlikely(cond) (cond)
#endif // !__GNUC__
#if defined(__GNUC__)
#define NOINLINE __attribute__((noinline))
#define ALWAYSINLINE __attribute__((always_inline))
#elif defined(_MSC_VER)
#define NOINLINE __declspec(noinline)
#define ALWAYSINLINE __forceinline
#else // !_MSC_VER
#define NOINLINE
#define ALWAYSINLINE
#endif // !_MSC_VER
#ifdef BRAHMA
#define IS_BRAHMA true
#else
#define IS_BRAHMA false
#endif
//! \endcond
#endif // MACROS_HPP_