diff options
author | Willem Jan Palenstijn <wjp@usecode.org> | 2017-02-09 18:01:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-09 18:01:03 +0100 |
commit | 981d6adc0e3c98a67403b92b1ec4cdb881c62fda (patch) | |
tree | cccde0fd4a3a2d92919338df4e162c9abfd079e1 /cuda | |
parent | 03c3e5b5043cc8cba9aceeb8641d497edd1be7cf (diff) | |
parent | 4c665b0d5af3841f20501a5dc01a23e671367856 (diff) | |
download | astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.gz astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.bz2 astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.tar.xz astra-981d6adc0e3c98a67403b92b1ec4cdb881c62fda.zip |
Merge pull request #93 from wjp/GPULink
GPULink support
Diffstat (limited to 'cuda')
-rw-r--r-- | cuda/3d/mem3d.cu | 24 | ||||
-rw-r--r-- | cuda/3d/mem3d.h | 5 |
2 files changed, 28 insertions, 1 deletions
diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index 2b26fe1..97be8a4 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -118,6 +118,13 @@ MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Me return ret; } +bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned int z) +{ + SMemHandle3D_internal& hnd = *handle.d.get(); + cudaError_t err = cudaMemset3D(hnd.ptr, 0, make_cudaExtent(sizeof(float)*x, y, z)); + return err == cudaSuccess; +} + bool freeGPUMemory(MemHandle3D handle) { size_t free = availableGPUMemory(); @@ -307,6 +314,23 @@ bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, co } +MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) +{ + cudaPitchedPtr ptr; + ptr.ptr = D_ptr; + ptr.xsize = sizeof(float) * x; + ptr.pitch = sizeof(float) * pitch; + ptr.ysize = y; + + SMemHandle3D_internal h; + h.ptr = ptr; + + MemHandle3D hnd; + hnd.d = boost::shared_ptr<SMemHandle3D_internal>(new SMemHandle3D_internal); + *hnd.d = h; + + return hnd; +} diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h index a0829e2..7a87ae6 100644 --- a/cuda/3d/mem3d.h +++ b/cuda/3d/mem3d.h @@ -80,6 +80,8 @@ enum Mem3DZeroMode { size_t availableGPUMemory(); int maxBlockDimension(); +MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); + MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero); bool copyToGPUMemory(const float *src, MemHandle3D dst, const SSubDimensions3D &pos); @@ -88,6 +90,8 @@ bool copyFromGPUMemory(float *dst, MemHandle3D src, const SSubDimensions3D &pos) bool freeGPUMemory(MemHandle3D handle); +bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned int z); + bool setGPUIndex(int index); @@ -97,7 +101,6 @@ bool BP(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, con bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, bool bShortScan, const float *pfFilter = 0); - } #endif |