MeshLib C++ Docs
Loading...
Searching...
No Matches
MRCudaAccessor.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRViewerFwd.h"
4#include "MRMesh/MRExpected.h"
5
6#include <functional>
7#include <memory>
8
9#ifndef MRVIEWER_NO_VOXELS
12#endif
13
14namespace MR
15{
18
19
20#ifndef MRVIEWER_NO_VOXELS
22#endif
23
25class MRVIEWER_CLASS CudaAccessor
26{
27public:
29 using CudaFreeMemoryFunc = std::function<size_t()>;
31 using CudaFwnConstructor = std::function<std::unique_ptr<IFastWindingNumber>( const Mesh& )>;
33 using CudaMeshProjectorConstructor = std::function<std::unique_ptr<IPointsToMeshProjector>()>;
35 using CudaPointsProjectorConstructor = std::function<std::unique_ptr<IPointsProjector>()>;
36
37#ifndef MRVIEWER_NO_VOXELS
39 using CudaComputePointsToDistanceVolumeConstructor = std::function<std::unique_ptr<IComputePointsToDistanceVolume>()>;
41 using CudaComputeToolDistanceConstructor = std::function<std::unique_ptr<IComputeToolDistance>()>;
42#endif
43
45 MRVIEWER_API static void setCudaAvailable( bool val, int maxDriverVersion, int runtimeVersion, int computeMajor, int computeMinor );
46 MRVIEWER_API static void setCudaFreeMemoryFunc( CudaFreeMemoryFunc freeMemFunc );
47 MRVIEWER_API static void setCudaFastWindingNumberConstructor( CudaFwnConstructor fwnCtor );
50
51#ifndef MRVIEWER_NO_VOXELS
54#endif
55
58 [[nodiscard]] MRVIEWER_API static bool isCudaSupportedByPlarform();
59
61 [[nodiscard]] MRVIEWER_API static bool isCudaAvailable();
62
64 [[nodiscard]] MRVIEWER_API static int getCudaMaxDriverSupportedVersion();
65
67 [[nodiscard]] MRVIEWER_API static int getCudaRuntimeVersion();
68
70 [[nodiscard]] MRVIEWER_API static int getComputeCapabilityMajor();
71
73 [[nodiscard]] MRVIEWER_API static int getComputeCapabilityMinor();
74
76 [[nodiscard]] MRVIEWER_API static size_t getCudaFreeMemory();
77
79 [[nodiscard]] MRVIEWER_API static std::unique_ptr<IFastWindingNumber> getCudaFastWindingNumber( const Mesh& mesh );
80
82 [[nodiscard]] MRVIEWER_API static std::unique_ptr<IPointsToMeshProjector> getCudaPointsToMeshProjector();
83
85 [[nodiscard]] MRVIEWER_API static std::unique_ptr<IPointsProjector> getCudaPointsProjector();
86
87#ifndef MRVIEWER_NO_VOXELS
89 [[nodiscard]] MRVIEWER_API static std::unique_ptr<IComputePointsToDistanceVolume> getCudaComputePointsToDistanceVolume();
90
92 [[nodiscard]] MRVIEWER_API static std::unique_ptr<IComputeToolDistance> getCudaComputeToolDistance();
93#endif
94
97 [[nodiscard]] MRVIEWER_API static size_t fastWindingNumberMeshMemory( const Mesh& mesh );
98
101 [[nodiscard]] MRVIEWER_API static size_t fromGridMemory( const Mesh& mesh, const Vector3i& dims );
102
107 [[nodiscard]] MRVIEWER_API static size_t fromVectorMemory( const Mesh& mesh, size_t inputSize );
108
113 [[nodiscard]] MRVIEWER_API static size_t selfIntersectionsMemory( const Mesh& mesh );
114
115private:
116 CudaAccessor() = default;
117 ~CudaAccessor() = default;
118
119 static CudaAccessor& instance_();
120
121 bool isCudaAvailable_ = false;
122 int maxDriverVersion_ = 0;
123 int runtimeVersion_ = 0;
124 int computeMajor_ = 0;
125 int computeMinor_ = 0;
126 CudaFreeMemoryFunc freeMemFunc_;
127 CudaFwnConstructor fwnCtor_;
130#ifndef MRVIEWER_NO_VOXELS
133#endif
134};
135
136}
abstract class for computing a volume of signed distances to points with normals
Definition MRPointsToDistanceVolume.h:46
static void setCudaFreeMemoryFunc(CudaFreeMemoryFunc freeMemFunc)
static std::unique_ptr< IComputePointsToDistanceVolume > getCudaComputePointsToDistanceVolume()
Returns cuda implementation of IComputePointsToDistanceVolume.
static int getComputeCapabilityMajor()
Returns Compute Capability major version of current device.
static bool isCudaSupportedByPlarform()
static int getCudaRuntimeVersion()
Returns version of current runtime.
static void setCudaAvailable(bool val, int maxDriverVersion, int runtimeVersion, int computeMajor, int computeMinor)
setup functions
static bool isCudaAvailable()
Returns true if CUDA is available on this computer.
static size_t fromGridMemory(const Mesh &mesh, const Vector3i &dims)
static size_t selfIntersectionsMemory(const Mesh &mesh)
returns amount of required GPU memory for CudaFastWindingNumber::calcSelfIntersections operation
std::function< std::unique_ptr< IComputeToolDistance >()> CudaComputeToolDistanceConstructor
Returns specific implementation of IComputeToolDistance interface that computes on GPU.
Definition MRCudaAccessor.h:41
std::function< std::unique_ptr< IFastWindingNumber >(const Mesh &)> CudaFwnConstructor
Returns specific implementation of IFastWindingNumber interface that computes windings on GPU.
Definition MRCudaAccessor.h:31
static int getCudaMaxDriverSupportedVersion()
Returns maximum supported by driver version.
static std::unique_ptr< IPointsProjector > getCudaPointsProjector()
Returns cuda implementation of IPointsProjector.
static void setCudaPointsProjectorConstructor(CudaPointsProjectorConstructor ppCtor)
std::function< std::unique_ptr< IComputePointsToDistanceVolume >()> CudaComputePointsToDistanceVolumeConstructor
Returns specific implementation of IComputePointsToDistanceVolume interface that computes on GPU.
Definition MRCudaAccessor.h:39
static std::unique_ptr< IFastWindingNumber > getCudaFastWindingNumber(const Mesh &mesh)
Returns cuda implementation of IFastWindingNumber.
static void setCudaMeshProjectorConstructor(CudaMeshProjectorConstructor mpCtor)
static void setCudaComputeToolDistanceConstructor(CudaComputeToolDistanceConstructor ctdCtor)
static size_t fromVectorMemory(const Mesh &mesh, size_t inputSize)
returns amount of required GPU memory for CudaFastWindingNumber::calcFromVector operation
std::function< size_t()> CudaFreeMemoryFunc
Returns amount of free memory on GPU.
Definition MRCudaAccessor.h:29
static void setCudaComputePointsToDistanceVolumeConstructor(CudaComputePointsToDistanceVolumeConstructor cpdvCtor)
static std::unique_ptr< IComputeToolDistance > getCudaComputeToolDistance()
Returns CUDA implementation of IComputeToolDistance.
std::function< std::unique_ptr< IPointsToMeshProjector >()> CudaMeshProjectorConstructor
Returns specific implementation of IPointsToMeshProjector interface projects on GPU.
Definition MRCudaAccessor.h:33
static void setCudaFastWindingNumberConstructor(CudaFwnConstructor fwnCtor)
static size_t getCudaFreeMemory()
Returns number of free bytes on cuda.
std::function< std::unique_ptr< IPointsProjector >()> CudaPointsProjectorConstructor
Returns specific implementation of IPointsProjector interface projects on GPU.
Definition MRCudaAccessor.h:35
static int getComputeCapabilityMinor()
Returns Compute Capability minor version of current device.
static std::unique_ptr< IPointsToMeshProjector > getCudaPointsToMeshProjector()
Returns cuda implementation of IPointsToMeshProjector.
static size_t fastWindingNumberMeshMemory(const Mesh &mesh)
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh.h:24