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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2014-02-10 19:53:03 +00:00
|
|
|
// 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
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2014-02-10 19:53:03 +00:00
|
|
|
// 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
|
|
|
|
2015-09-17 19:45:35 +00:00
|
|
|
#include <vtkm/StaticAssert.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/Types.h>
|
2014-02-10 19:53:03 +00:00
|
|
|
#include <vtkm/internal/Configure.h>
|
|
|
|
#include <vtkm/internal/ExportMacros.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_ERROR -2
|
2014-06-09 22:32:02 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_UNDEFINED -1
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_SERIAL 1
|
|
|
|
#define VTKM_DEVICE_ADAPTER_CUDA 2
|
|
|
|
#define VTKM_DEVICE_ADAPTER_TBB 3
|
2018-03-01 21:20:31 +00:00
|
|
|
#define VTKM_DEVICE_ADAPTER_OPENMP 4
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2017-06-23 18:50:34 +00:00
|
|
|
using DeviceAdapterId = vtkm::Int8;
|
|
|
|
using DeviceAdapterNameType = std::string;
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename DeviceAdapter>
|
2014-02-10 19:53:03 +00:00
|
|
|
struct DeviceAdapterTraits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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.
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_VALID_DEVICE_ADAPTER(Name, Id) \
|
|
|
|
namespace vtkm \
|
|
|
|
{ \
|
|
|
|
namespace cont \
|
|
|
|
{ \
|
|
|
|
struct VTKM_ALWAYS_EXPORT DeviceAdapterTag##Name \
|
|
|
|
{ \
|
|
|
|
}; \
|
|
|
|
template <> \
|
|
|
|
struct DeviceAdapterTraits<vtkm::cont::DeviceAdapterTag##Name> \
|
|
|
|
{ \
|
|
|
|
static DeviceAdapterId GetId() { return DeviceAdapterId(Id); } \
|
|
|
|
static DeviceAdapterNameType GetName() { return DeviceAdapterNameType(#Name); } \
|
2018-02-27 14:25:25 +00:00
|
|
|
static constexpr bool Valid = true; \
|
2017-05-18 14:29:41 +00:00
|
|
|
}; \
|
|
|
|
} \
|
2014-02-10 19:53:03 +00:00
|
|
|
}
|
|
|
|
|
2015-09-16 20:59:28 +00:00
|
|
|
/// Marks the tag named vtkm::cont::DeviceAdapterTagName and associated
|
2015-12-16 16:18:52 +00:00
|
|
|
/// structures as invalid to use. Always use this macro (in the base namespace)
|
2015-09-16 20:59:28 +00:00
|
|
|
/// when creating a device adapter.
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_INVALID_DEVICE_ADAPTER(Name, Id) \
|
|
|
|
namespace vtkm \
|
|
|
|
{ \
|
|
|
|
namespace cont \
|
|
|
|
{ \
|
2018-07-24 12:16:48 +00:00
|
|
|
struct VTKM_ALWAYS_EXPORT DeviceAdapterTag##Name \
|
2017-05-18 14:29:41 +00:00
|
|
|
{ \
|
|
|
|
}; \
|
|
|
|
template <> \
|
|
|
|
struct DeviceAdapterTraits<vtkm::cont::DeviceAdapterTag##Name> \
|
|
|
|
{ \
|
|
|
|
static DeviceAdapterId GetId() { return DeviceAdapterId(Id); } \
|
|
|
|
static DeviceAdapterNameType GetName() { return DeviceAdapterNameType(#Name); } \
|
2018-02-27 14:25:25 +00:00
|
|
|
static constexpr bool Valid = false; \
|
2017-05-18 14:29:41 +00:00
|
|
|
}; \
|
|
|
|
} \
|
2015-09-16 20:59:28 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 19:53:03 +00:00
|
|
|
/// 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
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag) \
|
2018-07-24 12:16:48 +00:00
|
|
|
VTKM_STATIC_ASSERT_MSG(::vtkm::cont::DeviceAdapterTraits<tag>::Valid, \
|
2017-05-18 14:29:41 +00:00
|
|
|
"Provided type is not a valid VTK-m device adapter tag.")
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2014-06-11 16:43:36 +00:00
|
|
|
#endif //vtk_m_cont_internal_DeviceAdapterTag_h
|