Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AnderBiguri committed Dec 5, 2024
2 parents 7e1c179 + 50a5c7b commit 1a65ff2
Show file tree
Hide file tree
Showing 21 changed files with 1,190 additions and 97 deletions.
14 changes: 7 additions & 7 deletions Common/CUDA/POCS_TV2.cu → Common/CUDA/GD_AwTV.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define MAXTHREADS 1024
#define MAX_BUFFER 60

#include "POCS_TV.hpp"
#include "GD_AwTV.hpp"



Expand All @@ -65,7 +65,7 @@ do { \
if (__err != cudaSuccess) { \
mexPrintf("%s \n",msg);\
cudaDeviceReset();\
mexErrMsgIdAndTxt("CBCT:CUDA:POCS_TV",cudaGetErrorString(__err));\
mexErrMsgIdAndTxt("CBCT:CUDA:GD_TV",cudaGetErrorString(__err));\
} \
} while (0)

Expand Down Expand Up @@ -278,15 +278,15 @@ void aw_pocs_tv(float* img,float* dst,float alpha,const long* image_size, int ma
int deviceCount = gpuids.GetLength();
cudaCheckErrors("Device query fail");
if (deviceCount == 0) {
mexErrMsgIdAndTxt("minimizeAwTV:POCS_TV2:GPUselect","There are no available device(s) that support CUDA\n");
mexErrMsgIdAndTxt("minimizeAwTV:GD_AwTV:GPUselect","There are no available device(s) that support CUDA\n");
}
//
// CODE assumes
// 1.-All available devices are usable by this code
// 2.-All available devices are equal, they are the same machine (warning thrown)
// Check the available devices, and if they are the same
if (!gpuids.AreEqualDevices()) {
mexWarnMsgIdAndTxt("minimizeAwTV:POCS_TV2:GPUselect","Detected one (or more) different GPUs.\n This code is not smart enough to separate the memory GPU wise if they have different computational times or memory limits.\n First GPU parameters used. If the code errors you might need to change the way GPU selection is performed.");
mexWarnMsgIdAndTxt("minimizeAwTV:GD_AwTV:GPUselect","Detected one (or more) different GPUs.\n This code is not smart enough to separate the memory GPU wise if they have different computational times or memory limits.\n First GPU parameters used. If the code errors you might need to change the way GPU selection is performed.");
}
int dev;

Expand Down Expand Up @@ -355,15 +355,15 @@ void aw_pocs_tv(float* img,float* dst,float alpha,const long* image_size, int ma

// Assert
if (mem_GPU_global< 3*mem_img_each_GPU+mem_auxiliary){
mexErrMsgIdAndTxt("minimizeAwTV:POCS_TV2:GPU","Assertion Failed. Logic behind splitting flawed! Please tell: [email protected]\n");
mexErrMsgIdAndTxt("minimizeAwTV:GD_AwTV:GPU","Assertion Failed. Logic behind splitting flawed! Please tell: [email protected]\n");
}
}


// Assert

if ((slices_per_split+buffer_length*2)*image_size[0]*image_size[1]* sizeof(float)!= mem_img_each_GPU){
mexErrMsgIdAndTxt("minimizeAwTV:POCS_TV2:GPU","Assertion Failed. Memory needed calculation broken! Please tell: [email protected]\n");
mexErrMsgIdAndTxt("minimizeAwTV:GD_AwTV:GPU","Assertion Failed. Memory needed calculation broken! Please tell: [email protected]\n");
}


Expand Down Expand Up @@ -395,7 +395,7 @@ void aw_pocs_tv(float* img,float* dst,float alpha,const long* image_size, int ma
unsigned long long buffer_pixels=buffer_length*image_size[0]*image_size[1];
float* buffer;
if(splits>1){
mexWarnMsgIdAndTxt("minimizeAwTV:POCS_TV2:Image_split","Your image can not be fully split between the available GPUs. The computation of minTV will be significantly slowed due to the image size.\nApproximated mathematics turned on for computational speed.");
mexWarnMsgIdAndTxt("minimizeAwTV:GD_AwTV:Image_split","Your image can not be fully split between the available GPUs. The computation of minTV will be significantly slowed due to the image size.\nApproximated mathematics turned on for computational speed.");
}else{
cudaMallocHost((void**)&buffer,buffer_length*image_size[0]*image_size[1]*sizeof(float));
}
Expand Down
4 changes: 2 additions & 2 deletions Common/CUDA/POCS_TV2.hpp → Common/CUDA/GD_AwTV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Codes : https://github.com/CERN/TIGRE



#ifndef POCS_TV_HPP
#define POCS_TV_HPP
#ifndef GD_AwTV_HPP
#define GD_AwTV_HPP
#include "TIGRE_common.hpp"
#include "GpuIds.hpp"

Expand Down
16 changes: 8 additions & 8 deletions Common/CUDA/POCS_TV.cu → Common/CUDA/GD_TV.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define MAXTHREADS 1024
#define MAX_BUFFER 60

#include "POCS_TV.hpp"
#include "GD_TV.hpp"
#include "gpuUtils.hpp"


Expand All @@ -65,7 +65,7 @@ do { \
if (__err != cudaSuccess) { \
mexPrintf("%s \n",msg);\
cudaDeviceReset();\
mexErrMsgIdAndTxt("POCS_TV:GPU",cudaGetErrorString(__err));\
mexErrMsgIdAndTxt("GD_TV:GPU",cudaGetErrorString(__err));\
} \
} while (0)

Expand Down Expand Up @@ -261,15 +261,15 @@ do { \
int deviceCount = gpuids.GetLength();
cudaCheckErrors("Device query fail");
if (deviceCount == 0) {
mexErrMsgIdAndTxt("POCS_TV:GPU","There are no available device(s) that support CUDA\n");
mexErrMsgIdAndTxt("GD_TV:GPU","There are no available device(s) that support CUDA\n");
}
//
// CODE assumes
// 1.-All available devices are usable by this code
// 2.-All available devices are equal, they are the same machine (warning thrown)
// Check the available devices, and if they are the same
if (!gpuids.AreEqualDevices()) {
mexWarnMsgIdAndTxt("minimizeTV:POCS_TV:GPUselect","Detected one (or more) different GPUs.\n This code is not smart enough to separate the memory GPU wise if they have different computational times or memory limits.\n First GPU parameters used. If the code errors you might need to change the way GPU selection is performed.");
mexWarnMsgIdAndTxt("minimizeTV:GD_TV:GPUselect","Detected one (or more) different GPUs.\n This code is not smart enough to separate the memory GPU wise if they have different computational times or memory limits.\n First GPU parameters used. If the code errors you might need to change the way GPU selection is performed.");
}

int dev;
Expand Down Expand Up @@ -339,15 +339,15 @@ do { \

// Assert
if (mem_GPU_global< 3*mem_img_each_GPU+mem_auxiliary){
mexErrMsgIdAndTxt("POCS_TV:GPU","Assertion Failed. Logic behind splitting flawed! Please tell: [email protected]\n");
mexErrMsgIdAndTxt("GD_TV:GPU","Assertion Failed. Logic behind splitting flawed! Please tell: [email protected]\n");
}
}


// Assert

if ((slices_per_split+buffer_length*2)*image_size[0]*image_size[1]* sizeof(float)!= mem_img_each_GPU){
mexErrMsgIdAndTxt("POCS_TV:GPU","Assertion Failed. Memory needed calculation broken! Please tell: [email protected]\n");
mexErrMsgIdAndTxt("GD_TV:GPU","Assertion Failed. Memory needed calculation broken! Please tell: [email protected]\n");
}


Expand Down Expand Up @@ -379,7 +379,7 @@ do { \
unsigned long long buffer_pixels=buffer_length*image_size[0]*image_size[1];
float* buffer;
if(splits>1){
mexWarnMsgIdAndTxt("minimizeTV:POCS_TV:Image_split","Your image can not be fully split between the available GPUs. The computation of minTV will be significantly slowed due to the image size.\nApproximated mathematics turned on for computational speed.");
mexWarnMsgIdAndTxt("minimizeTV:GD_TV:Image_split","Your image can not be fully split between the available GPUs. The computation of minTV will be significantly slowed due to the image size.\nApproximated mathematics turned on for computational speed.");
}else{
cudaMallocHost((void**)&buffer,buffer_length*image_size[0]*image_size[1]*sizeof(float));
}
Expand Down Expand Up @@ -690,7 +690,7 @@ void checkFreeMemory(const GpuIds& gpuids,size_t *mem_GPU_global){
cudaMemGetInfo(&memfree,&memtotal);
if(dev==0) *mem_GPU_global=memfree;
if(memfree<memtotal/2){
mexErrMsgIdAndTxt("POCS_TV:GPU","One (or more) of your GPUs is being heavily used by another program (possibly graphics-based).\n Free the GPU to run TIGRE\n");
mexErrMsgIdAndTxt("GD_TV:GPU","One (or more) of your GPUs is being heavily used by another program (possibly graphics-based).\n Free the GPU to run TIGRE\n");
}
cudaCheckErrors("Check mem error");

Expand Down
120 changes: 60 additions & 60 deletions Common/CUDA/POCS_TV.hpp → Common/CUDA/GD_TV.hpp
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
/*-------------------------------------------------------------------------
*
* Header for CUDA functions for Steepest descend in POCS-type algorithms.
*
* This file has the required headers for POCS_TV.cu
*
* CODE by Ander Biguri
*
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2015, University of Bath and CERN- European Organization for
Nuclear Research
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
Contact: [email protected]
Codes : https://github.com/CERN/TIGRE
---------------------------------------------------------------------------
*/







#ifndef POCS_TV_HPP
#define POCS_TV_HPP
#include "TIGRE_common.hpp"
#include "GpuIds.hpp"

void pocs_tv(float* img,float* dst,float alpha,const long* image_size, int maxIter, const GpuIds& gpuids);

void checkFreeMemory(const GpuIds& gpuids, size_t *mem_GPU_global);
/*-------------------------------------------------------------------------
*
* Header for CUDA functions for Steepest descend in POCS-type algorithms.
*
* This file has the required headers for POCS_TV.cu
*
* CODE by Ander Biguri
*
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2015, University of Bath and CERN- European Organization for
Nuclear Research
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
Contact: [email protected]
Codes : https://github.com/CERN/TIGRE
---------------------------------------------------------------------------
*/







#ifndef GD_TV_HPP
#define GD_TV_HPP
#include "TIGRE_common.hpp"
#include "GpuIds.hpp"

void pocs_tv(float* img,float* dst,float alpha,const long* image_size, int maxIter, const GpuIds& gpuids);

void checkFreeMemory(const GpuIds& gpuids, size_t *mem_GPU_global);
#endif
Loading

0 comments on commit 1a65ff2

Please sign in to comment.