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
|
|
|
|
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>
|
|
|
|
|
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
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace cont {
|
|
|
|
|
2015-12-16 16:18:52 +00:00
|
|
|
typedef vtkm::Int8 DeviceAdapterId;
|
|
|
|
typedef std::string DeviceAdapterNameType;
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
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.
|
2015-12-16 16:18:52 +00:00
|
|
|
#define VTKM_VALID_DEVICE_ADAPTER(Name, Id) \
|
2014-02-10 19:53:03 +00:00
|
|
|
namespace vtkm { \
|
|
|
|
namespace cont { \
|
2017-04-05 22:44:15 +00:00
|
|
|
struct VTKM_ALWAYS_EXPORT DeviceAdapterTag##Name { }; \
|
2014-02-10 19:53:03 +00:00
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTraits<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static DeviceAdapterId GetId() { \
|
2015-12-16 16:18:52 +00:00
|
|
|
return DeviceAdapterId(Id); \
|
|
|
|
} \
|
|
|
|
static DeviceAdapterNameType GetName() { \
|
|
|
|
return DeviceAdapterNameType(#Name); \
|
2014-02-10 19:53:03 +00:00
|
|
|
} \
|
2015-09-16 20:59:28 +00:00
|
|
|
static const bool Valid = true;\
|
2014-02-10 19:53:03 +00:00
|
|
|
}; \
|
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static const bool Valid = true; \
|
|
|
|
}; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
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.
|
2015-12-16 16:18:52 +00:00
|
|
|
#define VTKM_INVALID_DEVICE_ADAPTER(Name, Id) \
|
2015-09-16 20:59:28 +00:00
|
|
|
namespace vtkm { \
|
|
|
|
namespace cont { \
|
|
|
|
struct DeviceAdapterTag##Name { }; \
|
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTraits<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static DeviceAdapterId GetId() { \
|
2015-12-16 16:18:52 +00:00
|
|
|
return DeviceAdapterId(Id); \
|
|
|
|
} \
|
|
|
|
static DeviceAdapterNameType GetName() { \
|
|
|
|
return DeviceAdapterNameType(#Name); \
|
2015-09-16 20:59:28 +00:00
|
|
|
} \
|
|
|
|
static const bool Valid = false;\
|
|
|
|
}; \
|
|
|
|
template<> \
|
|
|
|
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
|
|
|
static const bool Valid = false; \
|
|
|
|
}; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
///
|
2014-02-10 19:53:03 +00:00
|
|
|
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag) \
|
2015-09-17 19:45:35 +00:00
|
|
|
VTKM_STATIC_ASSERT_MSG( \
|
2015-12-01 20:39:15 +00:00
|
|
|
::vtkm::cont::DeviceAdapterTagCheck<tag>::Valid, \
|
2014-10-22 13:24:04 +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
|