2014-02-10 19:53:03 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
|
|
|
// Copyright 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-02-10 19:53:03 +00:00
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
2014-03-07 15:19:09 +00:00
|
|
|
#ifndef vtk_m_cont_internal_DeviceAdapterTag_h
|
|
|
|
#define vtk_m_cont_internal_DeviceAdapterTag_h
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
#include <vtkm/internal/Configure.h>
|
|
|
|
#include <vtkm/internal/ExportMacros.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2015-08-12 19:08:45 +00:00
|
|
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
2014-02-10 19:53:03 +00:00
|
|
|
#include <boost/static_assert.hpp>
|
2015-08-12 19:08:45 +00:00
|
|
|
VTKM_THIRDPARTY_POST_INCLUDE
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2014-06-09 22:32:02 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_ERROR -2
|
|
|
|
#define VTKM_DEVICE_ADAPTER_UNDEFINED -1
|
2014-02-10 19:53:03 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_SERIAL 1
|
2014-11-26 17:19:46 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_CUDA 2
|
2015-05-29 14:38:28 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_TBB 3
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
#ifndef VTKM_DEVICE_ADAPTER
|
|
|
|
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
|
|
|
|
#endif // VTKM_DEVICE_ADAPTER
|
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace cont {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
typedef std::string DeviceAdapterId;
|
|
|
|
|
|
|
|
template<typename DeviceAdapter>
|
|
|
|
struct DeviceAdapterTraits;
|
|
|
|
|
|
|
|
template<typename DeviceAdapter>
|
|
|
|
struct DeviceAdapterTagCheck
|
|
|
|
{
|
|
|
|
static const bool Valid = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a tag named vtkm::cont::DeviceAdapterTagName and associated MPL
|
|
|
|
/// structures to use this tag. Always use this macro (in the base namespace)
|
|
|
|
/// when creating a device adapter.
|
|
|
|
#define VTKM_CREATE_DEVICE_ADAPTER(Name) \
|
|
|
|
namespace vtkm { \
|
|
|
|
namespace cont { \
|
|
|
|
struct DeviceAdapterTag##Name { }; \
|
|
|
|
namespace internal { \
|
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTraits<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static DeviceAdapterId GetId() { \
|
|
|
|
return DeviceAdapterId(#Name); \
|
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static const bool Valid = true; \
|
|
|
|
}; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Checks that the argument is a proper device adapter tag. This is a handy
|
|
|
|
/// concept check for functions and classes to make sure that a template
|
|
|
|
/// argument is actually a device adapter tag. (You can get weird errors
|
|
|
|
/// elsewhere in the code when a mistake is made.)
|
2014-10-22 13:24:04 +00:00
|
|
|
///
|
2014-02-10 19:53:03 +00:00
|
|
|
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag) \
|
2015-09-17 05:34:49 +00:00
|
|
|
VTKM_THIRDPARTY_PRE_INCLUDE \
|
2014-02-10 19:53:03 +00:00
|
|
|
BOOST_STATIC_ASSERT_MSG( \
|
|
|
|
::vtkm::cont::internal::DeviceAdapterTagCheck<tag>::Valid, \
|
2015-09-17 05:34:49 +00:00
|
|
|
"Provided type is not a valid VTK-m device adapter tag.") \
|
|
|
|
VTKM_THIRDPARTY_POST_INCLUDE
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_SERIAL
|
|
|
|
|
|
|
|
#include <vtkm/cont/internal/DeviceAdapterTagSerial.h>
|
|
|
|
#define VTKM_DEFAULT_DEVICE_ADAPTER_TAG ::vtkm::cont::DeviceAdapterTagSerial
|
|
|
|
|
2014-11-26 17:19:46 +00:00
|
|
|
#elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_CUDA
|
|
|
|
|
|
|
|
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
|
|
|
#define VTKM_DEFAULT_DEVICE_ADAPTER_TAG ::vtkm::cont::DeviceAdapterTagCuda
|
|
|
|
|
2015-05-29 14:38:28 +00:00
|
|
|
#elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_TBB
|
|
|
|
|
|
|
|
#include <vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h>
|
|
|
|
#define VTKM_DEFAULT_DEVICE_ADAPTER_TAG ::vtkm::cont::DeviceAdapterTagTBB
|
|
|
|
|
2014-02-11 17:34:56 +00:00
|
|
|
#elif VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_ERROR
|
|
|
|
|
|
|
|
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
|
|
|
#define VTKM_DEFAULT_DEVICE_ADAPTER_TAG ::vtkm::cont::DeviceAdapterTagError
|
|
|
|
|
2014-02-10 19:53:03 +00:00
|
|
|
#elif (VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_UNDEFINED) || !defined(VTKM_DEVICE_ADAPTER)
|
|
|
|
|
|
|
|
#ifndef VTKM_DEFAULT_DEVICE_ADAPTER_TAG
|
|
|
|
#warning If device adapter is undefined, VTKM_DEFAULT_DEVICE_ADAPTER_TAG must be defined.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#warning Unrecognized device adapter given.
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-06-11 16:43:36 +00:00
|
|
|
#endif //vtk_m_cont_internal_DeviceAdapterTag_h
|