mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
DeviceAdapter Tags now always exist, and contain if the device is valid.
Previously it was really hard to verify if a device adapter was valid. Since you would have to check for the existence of the tag. Now the tag always exists, but instead you query the traits of the DeviceAdapter to see if it is a valid adapter. This makes compiling with multiple backends alot easier.
This commit is contained in:
parent
cf32b430dc
commit
4d635d642b
@ -21,7 +21,10 @@
|
|||||||
#define vtk_m_cont_cuda_DeviceAdapterCuda_h
|
#define vtk_m_cont_cuda_DeviceAdapterCuda_h
|
||||||
|
|
||||||
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
||||||
|
|
||||||
|
#ifdef VTKM_ENABLE_CUDA
|
||||||
#include <vtkm/cont/cuda/internal/ArrayManagerExecutionCuda.h>
|
#include <vtkm/cont/cuda/internal/ArrayManagerExecutionCuda.h>
|
||||||
#include <vtkm/cont/cuda/internal/DeviceAdapterAlgorithmCuda.h>
|
#include <vtkm/cont/cuda/internal/DeviceAdapterAlgorithmCuda.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //vtk_m_cont_cuda_DeviceAdapterCuda_h
|
#endif //vtk_m_cont_cuda_DeviceAdapterCuda_h
|
||||||
|
@ -22,7 +22,13 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||||
|
|
||||||
|
//We always create the cuda tag when included, but we only mark it as
|
||||||
VTKM_CREATE_DEVICE_ADAPTER(Cuda);
|
//a valid tag when VTKM_ENABLE_CUDA is true. This is for easier development
|
||||||
|
//of multi-backend systems
|
||||||
|
#ifdef VTKM_ENABLE_CUDA
|
||||||
|
VTKM_VALID_DEVICE_ADAPTER(Cuda);
|
||||||
|
#else
|
||||||
|
VTKM_INVALID_DEVICE_ADAPTER(Cuda);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //vtk_m_cont_cuda_internal_DeviceAdapterTagCuda_h
|
#endif //vtk_m_cont_cuda_internal_DeviceAdapterTagCuda_h
|
||||||
|
@ -27,6 +27,6 @@
|
|||||||
/// point, you have to specify an appropriate DeviceAdapter or else get a
|
/// point, you have to specify an appropriate DeviceAdapter or else get a
|
||||||
/// compile error.
|
/// compile error.
|
||||||
///
|
///
|
||||||
VTKM_CREATE_DEVICE_ADAPTER(Error);
|
VTKM_VALID_DEVICE_ADAPTER(Error);
|
||||||
|
|
||||||
#endif //vtk_m_cont_internal_DeviceAdapterError_h
|
#endif //vtk_m_cont_internal_DeviceAdapterError_h
|
||||||
|
@ -61,7 +61,7 @@ struct DeviceAdapterTagCheck
|
|||||||
/// Creates a tag named vtkm::cont::DeviceAdapterTagName and associated MPL
|
/// Creates a tag named vtkm::cont::DeviceAdapterTagName and associated MPL
|
||||||
/// structures to use this tag. Always use this macro (in the base namespace)
|
/// structures to use this tag. Always use this macro (in the base namespace)
|
||||||
/// when creating a device adapter.
|
/// when creating a device adapter.
|
||||||
#define VTKM_CREATE_DEVICE_ADAPTER(Name) \
|
#define VTKM_VALID_DEVICE_ADAPTER(Name) \
|
||||||
namespace vtkm { \
|
namespace vtkm { \
|
||||||
namespace cont { \
|
namespace cont { \
|
||||||
struct DeviceAdapterTag##Name { }; \
|
struct DeviceAdapterTag##Name { }; \
|
||||||
@ -71,6 +71,7 @@ struct DeviceAdapterTagCheck
|
|||||||
static DeviceAdapterId GetId() { \
|
static DeviceAdapterId GetId() { \
|
||||||
return DeviceAdapterId(#Name); \
|
return DeviceAdapterId(#Name); \
|
||||||
} \
|
} \
|
||||||
|
static const bool Valid = true;\
|
||||||
}; \
|
}; \
|
||||||
template<> \
|
template<> \
|
||||||
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
||||||
@ -80,6 +81,31 @@ struct DeviceAdapterTagCheck
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Marks the tag named vtkm::cont::DeviceAdapterTagName and associated
|
||||||
|
/// structures as valid to use. Always use this macro (in the base namespace)
|
||||||
|
/// when creating a device adapter.
|
||||||
|
#define VTKM_INVALID_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); \
|
||||||
|
} \
|
||||||
|
static const bool Valid = false;\
|
||||||
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct DeviceAdapterTagCheck<vtkm::cont::DeviceAdapterTag##Name> { \
|
||||||
|
static const bool Valid = false; \
|
||||||
|
}; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Checks that the argument is a proper device adapter tag. This is a handy
|
/// 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
|
/// concept check for functions and classes to make sure that a template
|
||||||
/// argument is actually a device adapter tag. (You can get weird errors
|
/// argument is actually a device adapter tag. (You can get weird errors
|
||||||
|
@ -22,6 +22,6 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||||
|
|
||||||
VTKM_CREATE_DEVICE_ADAPTER(Serial);
|
VTKM_VALID_DEVICE_ADAPTER(Serial);
|
||||||
|
|
||||||
#endif //vtk_m_cont_internal_DeviceAdapterTagSerial_h
|
#endif //vtk_m_cont_internal_DeviceAdapterTagSerial_h
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
#define vtk_m_cont_tbb_DeviceAdapterTBB_h
|
#define vtk_m_cont_tbb_DeviceAdapterTBB_h
|
||||||
|
|
||||||
#include <vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h>
|
#include <vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h>
|
||||||
|
|
||||||
|
#ifdef VTKM_ENABLE_TBB
|
||||||
#include <vtkm/cont/tbb/internal/ArrayManagerExecutionTBB.h>
|
#include <vtkm/cont/tbb/internal/ArrayManagerExecutionTBB.h>
|
||||||
#include <vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h>
|
#include <vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //vtk_m_cont_tbb_DeviceAdapterTBB_h
|
#endif //vtk_m_cont_tbb_DeviceAdapterTBB_h
|
||||||
|
@ -22,7 +22,13 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||||
|
|
||||||
|
//We always create the tbb tag when included, but we only mark it as
|
||||||
VTKM_CREATE_DEVICE_ADAPTER(TBB);
|
//a valid tag when VTKM_ENABLE_TBB is true. This is for easier development
|
||||||
|
//of multi-backend systems
|
||||||
|
#ifdef VTKM_ENABLE_TBB
|
||||||
|
VTKM_VALID_DEVICE_ADAPTER(TBB);
|
||||||
|
#else
|
||||||
|
VTKM_INVALID_DEVICE_ADAPTER(TBB);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //vtk_m_cont_tbb_internal_DeviceAdapterTagTBB_h
|
#endif //vtk_m_cont_tbb_internal_DeviceAdapterTagTBB_h
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <vtkm/cont/testing/TestingDeviceAdapter.h>
|
#include <vtkm/cont/testing/TestingDeviceAdapter.h>
|
||||||
|
|
||||||
VTKM_CREATE_DEVICE_ADAPTER(TestAlgorithmGeneral);
|
VTKM_VALID_DEVICE_ADAPTER(TestAlgorithmGeneral);
|
||||||
|
|
||||||
namespace vtkm {
|
namespace vtkm {
|
||||||
namespace cont {
|
namespace cont {
|
||||||
|
Loading…
Reference in New Issue
Block a user