VTK  9.7.20261129
vtkmDataArrayFactory.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
59
60#ifndef vtkmDataArrayFactory_h
61#define vtkmDataArrayFactory_h
62
63#include "vtkAcceleratorsVTKmCoreModule.h" // For export macro
64#include "vtkObject.h"
65#include "vtkmlib/vtkmInitializer.h" // Need for initializing viskores
66
67#include <vector> // For std::vector
68
69VTK_ABI_NAMESPACE_BEGIN
70
71class vtkDataArray;
73
74class VTKACCELERATORSVTKMCORE_EXPORT vtkmDataArrayFactory : public vtkObject
75{
76public:
79 void PrintSelf(ostream& os, vtkIndent indent) override;
80
82
88
90
93 vtkSetMacro(NumberOfComponents, int);
94 vtkGetMacro(NumberOfComponents, int);
96
98
101 vtkSetMacro(DataType, int);
102 vtkGetMacro(DataType, int);
104
112
118
123
138
145 static bool IsMemorySpaceAvailable(const char* space);
146
148
160 static vtkTypeUInt64 GetLevelZeroDriverHandle();
161 static vtkTypeUInt64 GetLevelZeroDeviceHandle();
162 static vtkTypeUInt64 GetLevelZeroContextHandle();
164
165protected:
168
171 int DataType = 10; // VTK_FLOAT
172
173 std::vector<vtkMemoryDescriptor*> Buffers;
174
175private:
177 void operator=(const vtkmDataArrayFactory&) = delete;
178
179 // Viskores has to be initialized before any of its devices is touched, and
180 // this class is the one place in Core that hands it device memory. Every
181 // vtkm *filter* carries this member; nothing in Core did, so a program that
182 // only wrapped external memory -- which is exactly what the DLPack import
183 // path does -- never initialized it. On a Kokkos-backed build that is not a
184 // warning: the first host read of a device array calls Kokkos::HIP::HIP(),
185 // which calls host_abort(). The process dies with no exception to catch.
186 vtkmInitializer Initializer;
187};
188
189VTK_ABI_NAMESPACE_END
190#endif // vtkmDataArrayFactory_h
a simple class to control print indentation
Definition vtkIndent.h:108
Describes a memory buffer on host or device, and who keeps it alive.
~vtkmDataArrayFactory() override
static bool IsMemorySpaceAvailable(const char *space)
Whether this build's Viskores can hold memory of the space named ("host", "cuda", "hip",...
static vtkTypeUInt64 GetLevelZeroContextHandle()
The Level Zero handles of the SYCL queue Viskores runs on, as integers: ze_driver_handle_t,...
void ClearBuffers()
Drop all added descriptors without creating an array.
static vtkTypeUInt64 GetLevelZeroDriverHandle()
The Level Zero handles of the SYCL queue Viskores runs on, as integers: ze_driver_handle_t,...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddBuffer(vtkMemoryDescriptor *descriptor)
Add a buffer descriptor.
std::vector< vtkMemoryDescriptor * > Buffers
static vtkTypeUInt64 GetLevelZeroDeviceHandle()
The Level Zero handles of the SYCL queue Viskores runs on, as integers: ze_driver_handle_t,...
static vtkmDataArrayFactory * New()
int GetNumberOfBuffers() const
Number of buffers added so far.
vtkDataArray * CreateArray()
Create the vtkmDataArray, or nullptr on error.
#define vtkDataArray
int vtkIdType
Definition vtkType.h:366
#define VTK_NEWINSTANCE