VTK  9.7.20261114
vtkDeviceMemory.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
28
29#ifndef vtkDeviceMemory_h
30#define vtkDeviceMemory_h
31
32#include "vtkCommonCoreModule.h" // For export macro
33#include "vtkDataArray.h" // For vtkDataArray::MemorySpace
34
35#include <cstddef>
36#include <string>
37
38VTK_ABI_NAMESPACE_BEGIN
39class VTKCOMMONCORE_EXPORT vtkDeviceMemory
40{
41public:
46 static bool SpaceFromName(const char* name, vtkDataArray::MemorySpace& space);
47
51 static const char* NameOf(vtkDataArray::MemorySpace space);
52
57 static bool IsAvailable(vtkDataArray::MemorySpace space, std::string* why = nullptr);
58
63 static bool IsDevicePointer(
64 vtkDataArray::MemorySpace space, const void* pointer, std::string* why = nullptr);
65
76 static bool CopyToHost(vtkDataArray::MemorySpace space, void* destination, const void* source,
77 std::size_t bytes, std::string* why = nullptr);
78
85 static int DeviceOrdinal(
86 vtkDataArray::MemorySpace space, const void* pointer, std::string* why = nullptr);
87
89
98 static void SetLevelZeroContext(void* driver, void* device, void* context);
99 static bool HasLevelZeroContext();
101 void*& driver, void*& device, void*& context, std::string* why = nullptr);
103};
104
105VTK_ABI_NAMESPACE_END
106#endif
107// VTK-HeaderTest-Exclude: vtkDeviceMemory.h
reads GPU memory through the vendor's runtime, loaded when first needed
static const char * NameOf(vtkDataArray::MemorySpace space)
The name of a device memory space, as vtkMemoryDescriptor spells it.
static int DeviceOrdinal(vtkDataArray::MemorySpace space, const void *pointer, std::string *why=nullptr)
The number of the device pointer is on, as the vendor's runtime counts devices (and DLPack's device_i...
static bool CopyToHost(vtkDataArray::MemorySpace space, void *destination, const void *source, std::size_t bytes, std::string *why=nullptr)
Copy bytes from device memory at source to host memory at destination.
static bool IsDevicePointer(vtkDataArray::MemorySpace space, const void *pointer, std::string *why=nullptr)
Whether pointer is memory of space that the runtime knows: device or managed memory,...
static bool HasLevelZeroContext()
VTK's Level Zero context and the driver and device it is on (the ze_*_handle_ts).
static void SetLevelZeroContext(void *driver, void *device, void *context)
VTK's Level Zero context and the driver and device it is on (the ze_*_handle_ts).
static bool IsAvailable(vtkDataArray::MemorySpace space, std::string *why=nullptr)
Whether the runtime for space could be loaded.
static bool SpaceFromName(const char *name, vtkDataArray::MemorySpace &space)
The memory space a vtkMemoryDescriptor names ("cuda", "hip", "level_zero").
static bool GetLevelZeroContext(void *&driver, void *&device, void *&context, std::string *why=nullptr)
VTK's Level Zero context and the driver and device it is on (the ze_*_handle_ts).
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)