vtk-m/vtkm/cont/RuntimeDeviceInformation.h
Kenneth Moreland 8f7b0d18be Add Buffer class
The buffer class encapsulates the movement of raw C arrays between
host and devices.

The `Buffer` class itself is not associated with any device. Instead,
`Buffer` is used in conjunction with a new templated class named
`DeviceAdapterMemoryManager` that can allocate data on a given
device and transfer data as necessary. `DeviceAdapterMemoryManager`
will eventually replace the more complicated device adapter classes
that manage data on a device.

The code in `DeviceAdapterMemoryManager` is actually enclosed in
virtual methods. This allows us to limit the number of classes that
need to be compiled for a device. Rather, the implementation of
`DeviceAdapterMemoryManager` is compiled once with whatever compiler
is necessary, and then the `RuntimeDeviceInformation` is used to
get the correct object instance.
2020-06-25 14:01:39 -06:00

61 lines
2.2 KiB
C++

//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_RuntimeDeviceInformation_h
#define vtk_m_cont_RuntimeDeviceInformation_h
#include <vtkm/cont/DeviceAdapterTag.h>
#include <vtkm/cont/internal/DeviceAdapterMemoryManager.h>
#include <vtkm/internal/ExportMacros.h>
namespace vtkm
{
namespace cont
{
/// A class that can be used to determine if a given device adapter
/// is supported on the current machine at runtime. This is very important
/// for device adapters where a physical hardware requirements such as a GPU
/// or a Accelerator Card is needed for support to exist.
///
///
class VTKM_CONT_EXPORT RuntimeDeviceInformation
{
public:
/// Returns the name corresponding to the device adapter id. If @a id is
/// not recognized, `InvalidDeviceId` is returned. Queries for a
/// name are all case-insensitive.
VTKM_CONT
DeviceAdapterNameType GetName(DeviceAdapterId id) const;
/// Returns the id corresponding to the device adapter name. If @a name is
/// not recognized, DeviceAdapterTagUndefined is returned.
VTKM_CONT
DeviceAdapterId GetId(DeviceAdapterNameType name) const;
/// Returns true if the given device adapter is supported on the current
/// machine.
///
VTKM_CONT
bool Exists(DeviceAdapterId id) const;
/// Returns a reference to a `DeviceAdapterMemoryManager` that will work with the
/// given device. This method will throw an exception if the device id is not a
/// real device (for example `DeviceAdapterTagAny`). If the device in question is
/// not valid, a `DeviceAdapterMemoryManager` will be returned, but attempting to
/// call any of the methods will result in a runtime exception.
///
VTKM_CONT
vtkm::cont::internal::DeviceAdapterMemoryManagerBase& GetMemoryManager(DeviceAdapterId id) const;
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_RuntimeDeviceInformation_h