Commit c42b2cc8 authored by Marc Modat's avatar Marc Modat

Added multiple CPU/GPU comparison - Added a class to define the cuda block...

Added multiple CPU/GPU comparison - Added a class to define the cuda block sizes based no the cuda capability - made sure uint is used for all nvox
parent f7fe46be
......@@ -156,12 +156,28 @@ if(USE_CUDA)
if(NOT COMPILE_RESULT_VAR)
message(STATUS "The code to check the presence of a CUDA-enabled card failed.")
message(STATUS "The USE_CUDA flag has been turned OFF.")
set(USE_CUDA false)
else(NOT COMPILE_RESULT_VAR)
# Check if the executable return failure
if(RUN_RESULT_VAR)
message(STATUS "No CUDA-enabled card has been detected.")
message(STATUS "Result message: ${RUN_RESULT_VAR}")
message(STATUS "Error message: ${RUN_OUTPUT_VAR}")
message(STATUS "The USE_CUDA flag has been turned OFF.")
set(USE_CUDA false)
else(RUN_RESULT_VAR)
# Check if ptxas information should be displayed
set(CUDA_CAPABILITY "" CACHE STRING "CUDA capability to use to generate the ptxas information (1.0, 2.0, 3.0) [0]")
if(CUDA_CAPABILITY EQUAL "1.0")
set(CUDA_NVCC_FLAGS
"${CUDA_NVCC_FLAGS} --ptxas-options=-v --generate-code arch=compute_10,code=sm_10")
elseif(CUDA_CAPABILITY EQUAL "2.0")
set(CUDA_NVCC_FLAGS
"${CUDA_NVCC_FLAGS} --ptxas-options=-v --generate-code arch=compute_20,code=sm_20")
elseif(CUDA_CAPABILITY EQUAL "3.0")
set(CUDA_NVCC_FLAGS
"${CUDA_NVCC_FLAGS} --ptxas-options=-v --generate-code arch=compute_30,code=sm_30")
endif(CUDA_CAPABILITY EQUAL "1.0")
# The CUDA implementation is used
add_definitions(-D_USE_CUDA)
message(STATUS "Found CUDA and a CUDA-enabled card - the GPU code will be compiled.")
......
......@@ -6,8 +6,8 @@ add_executable(reg_tools reg_tools.cpp)
target_link_libraries(reg_tools _reg_resampling _reg_localTransformation _reg_tools _reg_globalTransformation _reg_ReadWriteImage)
#-----------------------------------------------------------------------------
add_executable(reg_resample reg_resample.cpp)
target_link_libraries(reg_resample _reg_resampling _reg_localTransformation _reg_tools _reg_globalTransformation _reg_ReadWriteImage)
#-----------------------------------------------------------------------------
target_link_libraries(reg_resample _reg_resampling _reg_localTransformation _reg_tools _reg_globalTransformation _reg_ReadWriteImage)
#-----------------------------------------------------------------------------
add_executable(reg_ppcnr reg_ppcnr.cpp)
target_link_libraries(reg_ppcnr _reg_ReadWriteImage)
#-----------------------------------------------------------------------------
......
......@@ -9,24 +9,22 @@
*
*/
#ifndef _MM_ALADIN_CPP
#define _MM_ALADIN_CPP
#include "_reg_ReadWriteImage.h"
#include "_reg_aladin_sym.h"
#include "_reg_tools.h"
#include "reg_aladin.h"
#ifdef _WINDOWS
#include <time.h>
# include <time.h>
#endif
#ifdef _USE_NR_DOUBLE
#define PrecisionTYPE double
# define PrecisionTYPE double
#else
#define PrecisionTYPE float
# define PrecisionTYPE float
#endif
void PetitUsage(char *exec)
......
......@@ -79,15 +79,18 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
reg_checkAndCorrectDimension(tempImage);
if(sizeof(PrecisionTYPE)==sizeof(double))
reg_tools_changeDatatype<double>(tempImage);
else reg_tools_changeDatatype<float>(tempImage);
if(average_image->nvox!=tempImage->nvox){
fprintf(stderr, "[!] All images must have the same size. Error when processing: %s\n", argv[i]);
return EXIT_FAILURE;
}
reg_tools_addSubMulDivImages(average_image,tempImage,average_image,0);
reg_tools_addImageToImage(average_image,tempImage,average_image);
imageTotalNumber++;
nifti_image_free(tempImage);tempImage=NULL;
}
reg_tools_addSubMulDivValue(average_image,average_image,(float)imageTotalNumber,3);
reg_tools_divideValueToImage(average_image,average_image,(float)imageTotalNumber);
reg_io_WriteImageFile(average_image,argv[1]);
nifti_image_free(average_image);
}
......@@ -103,7 +106,7 @@ int main(int argc, char **argv)
}
else{
fprintf(stderr,"The specified input affine file (%s) can not be read\n",argv[m+2]);
exit(1);
reg_exit(1);
}
// Read the current matrix file
std::ifstream affineFile;
......
......@@ -12,21 +12,21 @@
#include "_reg_ReadWriteImage.h"
#include "_reg_f3d2.h"
#include "reg_f3d.h"
#include <float.h>
#include <limits>
#ifdef _USE_CUDA
#include "_reg_f3d_gpu.h"
# include "_reg_f3d_gpu.h"
#endif
#include "float.h"
#include <limits>
#ifdef _WINDOWS
#include <time.h>
# include <time.h>
#endif
#ifdef _USE_NR_DOUBLE
#define PrecisionTYPE double
# define PrecisionTYPE double
#else
#define PrecisionTYPE float
# define PrecisionTYPE float
#endif
void HelpPenaltyTerm()
......@@ -594,75 +594,73 @@ int main(int argc, char **argv)
if(linearEnergyWeight0==linearEnergyWeight0 ||
linearEnergyWeight1==linearEnergyWeight1 ||
L2NormWeight==L2NormWeight){
fprintf(stderr,"NiftyReg ERROR CUDA] The linear elasticity has not been implemented with CUDA yet. Exit.\n");
exit(1);
fprintf(stderr,"\n[NiftyReg WARNING CUDA] The linear elasticity has not been implemented with CUDA yet.\n");
fprintf(stderr,"[NiftyReg WARNING CUDA] GPU implementation has been turned off.\n");
useGPU=false;
}
if(useSym){
fprintf(stderr,"\n[NiftyReg ERROR CUDA] GPU implementation of the symmetric registration is not available yet. Exit\n");
exit(1);
fprintf(stderr,"\n[NiftyReg WARNING CUDA] GPU implementation of the symmetric registration is not available yet.\n");
fprintf(stderr,"[NiftyReg WARNING CUDA] GPU implementation has been turned off.\n");
useGPU=false;
}
if(useVel){
fprintf(stderr,"\n[NiftyReg ERROR CUDA] GPU implementation of velocity field parametrisartion is not available yet. Exit\n");
exit(1);
fprintf(stderr,"\n[NiftyReg WARNING CUDA] GPU implementation of velocity field parametrisartion is not available yet.\n");
fprintf(stderr,"[NiftyReg WARNING CUDA] GPU implementation has been turned off.\n");
useGPU=false;
}
if((referenceImage->dim[4]==1 && floatingImage->dim[4]==1) ||
(referenceImage->dim[4]==2 && floatingImage->dim[4]==2)){
// Set up the cuda card and display some relevant information
int major, minor;
if(cudaCommon_setCUDACard(&dev, &ctx, major, minor, verbose)) exit(1);
// Creat the registration object using the GPU class
REG = new reg_f3d_gpu(referenceImage->nt, floatingImage->nt);
if(!(referenceImage->dim[4]==1 && floatingImage->dim[4]==1) &&
!(referenceImage->dim[4]==2 && floatingImage->dim[4]==2)){
fprintf(stderr,"\n[NiftyReg WARNING CUDA] The GPU implementation only handle 1 to 1 or 2 to 2 image(s) registration\n");
fprintf(stderr,"[NiftyReg WARNING CUDA] GPU implementation has been turned off.\n");
useGPU=false;
}
else{
fprintf(stderr,"[NiftyReg ERROR] The GPU implementation only handle 1 to 1 or 2 to 2 image(s) registration\n");
exit(1);
// Set up the cuda card and display some relevant information and check if the card is suitable
int major, minor;
if(cudaCommon_setCUDACard(&dev, &ctx, major, minor, verbose)){
fprintf(stderr,"\n[NiftyReg ERROR CUDA] Error while detecting a CUDA card\n");
fprintf(stderr,"[NiftyReg WARNING CUDA] GPU implementation has been turned off.\n");
useGPU=false;
}
}
else
#endif
{
if(useSym){
REG = new reg_f3d_sym<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
// Create the registration object using the GPU class
if(useGPU)
REG = new reg_f3d_gpu(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
if(verbose==true){
if(verbose==true)
#endif // NDEBUG
printf("\n[NiftyReg F3D SYM] CPU implementation is used\n");
printf("\n[NiftyReg F3D GPU] GPU implementation is used\n");
}
#endif
if(useSym && REG==NULL){
REG = new reg_f3d_sym<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
}
if(verbose==true)
#endif // NDEBUG
}
else if(useVel){
REG = new reg_f3d2<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
if(verbose==true){
#endif
printf("\n[NiftyReg F3D2] CPU implementation is used\n");
printf("\n[NiftyReg F3D SYM] CPU implementation is used\n");
}
else if(useVel && REG==NULL){
REG = new reg_f3d2<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
}
if(verbose==true)
#endif
}
else{
REG = new reg_f3d<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
if(verbose==true){
#endif // NDEBUG
printf("\n[NiftyReg F3D] CPU implementation is used\n");
printf("\n[NiftyReg F3D2] CPU implementation is used\n");
}
else if(REG==NULL){
REG = new reg_f3d<PrecisionTYPE>(referenceImage->nt, floatingImage->nt);
#ifdef NDEBUG
}
if(verbose==true)
#endif // NDEBUG
}
printf("\n[NiftyReg F3D] CPU implementation is used\n");
}
#ifdef _OPENMP
int maxThreadNumber = omp_get_max_threads();
#ifdef NDEBUG
if(verbose==true){
if(verbose==true)
#endif // NDEBUG
printf("[NiftyReg F3D] OpenMP is used with %i thread(s)\n", maxThreadNumber);
#ifdef NDEBUG
}
#endif // NDEBUG
#endif // _OPENMP
// Set the reg_f3d parameters
......@@ -931,7 +929,7 @@ int main(int argc, char **argv)
outputWarpedImage=NULL;
#ifdef _USE_CUDA
}
cuCtxDetach(ctx);
cudaCommon_unsetCUDACard(&ctx);
#endif
// Erase the registration object
delete REG;
......
......@@ -243,7 +243,7 @@ int main(int argc, char **argv)
affineMatrix2.m[2][1]=affineMatrix.m[2][1];
affineMatrix2.m[2][2]=affineMatrix.m[2][2];
float affineDet = nifti_mat33_determ(affineMatrix2);
reg_tools_addSubMulDivValue(jacobianImage,jacobianImage,affineDet,2);
reg_tools_multiplyValueToImage(jacobianImage,jacobianImage,affineDet);
}
// Export the Jacobian determinant map
......@@ -300,11 +300,11 @@ int main(int argc, char **argv)
else jacobianImage->dim[5] = jacobianImage->nu = 4;
jacobianImage->datatype = currentDatatype;
jacobianImage->nbyper = currentNbyper;
jacobianImage->nvox = jacobianImage->nx * jacobianImage->ny * jacobianImage->nz *
jacobianImage->nt * jacobianImage->nu;
jacobianImage->nvox = (size_t)jacobianImage->nx * (size_t)jacobianImage->ny * (size_t)jacobianImage->nz *
(size_t)jacobianImage->nt * (size_t)jacobianImage->nu;
jacobianImage->data = (void *)calloc(jacobianImage->nvox, jacobianImage->nbyper);
size_t voxelNumber=image->nx*image->ny*image->nz;
size_t voxelNumber=(size_t)image->nx*image->ny*image->nz;
mat33* jacobianMatricesArray=(mat33 *)malloc(voxelNumber*sizeof(mat33));
// Compute the matrices
......
......@@ -157,7 +157,7 @@ int main(int argc, char **argv)
nifti_image_free(source);
makesource->ndim=makesource->dim[0] = 4;
makesource->nt = makesource->dim[4] = atoi(argv[++i]);
makesource->nvox=makesource->nx*makesource->nz*makesource->ny*makesource->nt;
makesource->nvox =(size_t)makesource->nx*(size_t)makesource->nz*(size_t)makesource->ny*(size_t)makesource->nt;
makesource->data = (void *)malloc(makesource->nvox * makesource->nbyper);
char *temp_data = reinterpret_cast<char *>(makesource->data);
for(int ii=0;ii<makesource->nt;ii++){ // fill with file data
......@@ -635,7 +635,7 @@ int main(int argc, char **argv)
nifti_image *stores = nifti_copy_nim_info(images);
stores->ndim=stores->dim[0]=3;
stores->nt=stores->dim[4]=1;
stores->nvox=stores->nx*stores->ny*stores->nz;
stores->nvox =(size_t)stores->nx*(size_t)stores->ny*(size_t)stores->nz;
stores->data = (void *)calloc(stores->nvox,images->nbyper);
nifti_image *storet = nifti_copy_nim_info(stores);
......@@ -703,7 +703,7 @@ int main(int argc, char **argv)
printf("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf("Registering image %i of %i \n", imageNumber+1,images->nt);
printf("'%s' \n",regCommandB);
if(!system(regCommandB)){
if(system(regCommandB)){
fprintf(stderr, "Error while running the following command:\n%s\n",regCommandB);
exit(EXIT_FAILURE);
}
......
......@@ -330,7 +330,8 @@ int main(int argc, char **argv)
deformationFieldImage->pixdim[5]=deformationFieldImage->du=1.0;
deformationFieldImage->dim[6]=deformationFieldImage->nv=1;deformationFieldImage->pixdim[6]=deformationFieldImage->dv=1.0;
deformationFieldImage->dim[7]=deformationFieldImage->nw=1;deformationFieldImage->pixdim[7]=deformationFieldImage->dw=1.0;
deformationFieldImage->nvox=deformationFieldImage->nx*deformationFieldImage->ny*deformationFieldImage->nz*deformationFieldImage->nt*deformationFieldImage->nu;
deformationFieldImage->nvox =(size_t)deformationFieldImage->nx*(size_t)deformationFieldImage->ny*(size_t)deformationFieldImage->nz*
(size_t)deformationFieldImage->nt*(size_t)deformationFieldImage->nu;
deformationFieldImage->datatype = currentDatatype;
deformationFieldImage->nbyper = currentNbyper;
deformationFieldImage->data = (void *)calloc(deformationFieldImage->nvox, deformationFieldImage->nbyper);
......@@ -390,7 +391,8 @@ int main(int argc, char **argv)
resultImage->scl_inter=floatingImage->scl_inter;
resultImage->datatype = floatingImage->datatype;
resultImage->nbyper = floatingImage->nbyper;
resultImage->nvox = resultImage->dim[1] * resultImage->dim[2] * resultImage->dim[3] * resultImage->dim[4];
resultImage->nvox = (size_t)resultImage->dim[1] * (size_t)resultImage->dim[2] *
(size_t)resultImage->dim[3] * (size_t)resultImage->dim[4];
resultImage->data = (void *)calloc(resultImage->nvox, resultImage->nbyper);
reg_resampleImage(floatingImage,
......
......@@ -280,10 +280,22 @@ int main(int argc, char **argv)
nifti_image *resultImage = nifti_copy_nim_info(image);
resultImage->data = (void *)malloc(resultImage->nvox * resultImage->nbyper);
if(image2!=NULL)
reg_tools_addSubMulDivImages(image, image2, resultImage, flag->operationTypeFlag);
else reg_tools_addSubMulDivValue(image, resultImage, param->operationValue, flag->operationTypeFlag);
if(image2!=NULL){
switch(flag->operationTypeFlag){
case 0:reg_tools_addImageToImage(image, image2, resultImage);break;
case 1:reg_tools_substractImageToImage(image, image2, resultImage);break;
case 2:reg_tools_multiplyImageToImage(image, image2, resultImage);break;
case 3:reg_tools_divideImageToImage(image, image2, resultImage);break;
}
}
else{
switch(flag->operationTypeFlag){
case 0:reg_tools_addValueToImage(image, resultImage, param->operationValue);break;
case 1:reg_tools_substractValueToImage(image, resultImage, param->operationValue);break;
case 2:reg_tools_multiplyValueToImage(image, resultImage, param->operationValue);break;
case 3:reg_tools_divideValueToImage(image, resultImage, param->operationValue);break;
}
}
if(flag->outputImageFlag)
reg_io_WriteImageFile(resultImage,param->outputImageName);
else reg_io_WriteImageFile(resultImage,"output.nii");
......
......@@ -311,7 +311,7 @@ int main(int argc, char **argv)
std::ifstream infile(param->tpsTextFilename);
if(!infile){
fprintf(stderr,"[ERROR] Can not open the file %s\n", param->tpsTextFilename);
exit(1);
reg_exit(1);
}
float val;
while(!infile.eof()){
......@@ -324,7 +324,7 @@ int main(int argc, char **argv)
else if(referenceImage->ndim==3) landmarkNumber=values.size()/6;
else{
fprintf(stderr,"[ERROR] The reference image is expected to be of dimension 2 or 3\n");
exit(1);
reg_exit(1);
}
printf("[NiftyReg] Landmark number %i\n", (int)landmarkNumber);
......@@ -390,7 +390,7 @@ int main(int argc, char **argv)
if(referenceImage->nz>1)
outputImage->nu=outputImage->dim[5]=3;
else outputImage->nu=outputImage->dim[5]=2;
outputImage->nvox=outputImage->nx*
outputImage->nvox =outputImage->nx*
outputImage->ny *
outputImage->nz *
outputImage->nt *
......@@ -430,7 +430,8 @@ int main(int argc, char **argv)
deformationFieldImage->pixdim[5]=deformationFieldImage->du=1.0;
deformationFieldImage->dim[6]=deformationFieldImage->nv=1;deformationFieldImage->pixdim[6]=deformationFieldImage->dv=1.0;
deformationFieldImage->dim[7]=deformationFieldImage->nw=1;deformationFieldImage->pixdim[7]=deformationFieldImage->dw=1.0;
deformationFieldImage->nvox=deformationFieldImage->nx*deformationFieldImage->ny*deformationFieldImage->nz*deformationFieldImage->nt*deformationFieldImage->nu;
deformationFieldImage->nvox =(size_t)deformationFieldImage->nx*(size_t)deformationFieldImage->ny*(size_t)deformationFieldImage->nz*
(size_t)deformationFieldImage->nt*(size_t)deformationFieldImage->nu;
deformationFieldImage->datatype = controlPointImage->datatype;
deformationFieldImage->nbyper = controlPointImage->nbyper;
deformationFieldImage->data = (void *)calloc(deformationFieldImage->nvox, deformationFieldImage->nbyper);
......@@ -500,7 +501,8 @@ int main(int argc, char **argv)
deformationFieldImage->pixdim[5]=deformationFieldImage->du=1.0;
deformationFieldImage->dim[6]=deformationFieldImage->nv=1;deformationFieldImage->pixdim[6]=deformationFieldImage->dv=1.0;
deformationFieldImage->dim[7]=deformationFieldImage->nw=1;deformationFieldImage->pixdim[7]=deformationFieldImage->dw=1.0;
deformationFieldImage->nvox=deformationFieldImage->nx*deformationFieldImage->ny*deformationFieldImage->nz*deformationFieldImage->nt*deformationFieldImage->nu;
deformationFieldImage->nvox =(size_t)deformationFieldImage->nx*(size_t)deformationFieldImage->ny*(size_t)deformationFieldImage->nz*
(size_t)deformationFieldImage->nt*(size_t)deformationFieldImage->nu;
deformationFieldImage->datatype = firstControlPointImage->datatype;
deformationFieldImage->nbyper = firstControlPointImage->nbyper;
deformationFieldImage->data = (void *)calloc(deformationFieldImage->nvox, deformationFieldImage->nbyper);
......@@ -705,9 +707,9 @@ int main(int argc, char **argv)
outputDeformationFieldImage->pixdim[6]=outputDeformationFieldImage->dv=1.0;
outputDeformationFieldImage->dim[7]=outputDeformationFieldImage->nw=1;
outputDeformationFieldImage->pixdim[7]=outputDeformationFieldImage->dw=1.0;
outputDeformationFieldImage->nvox=outputDeformationFieldImage->nx*outputDeformationFieldImage->ny*
outputDeformationFieldImage->nz*outputDeformationFieldImage->nt*
outputDeformationFieldImage->nu;
outputDeformationFieldImage->nvox =(size_t)outputDeformationFieldImage->nx*(size_t)outputDeformationFieldImage->ny*
(size_t)outputDeformationFieldImage->nz*(size_t)outputDeformationFieldImage->nt*
(size_t)outputDeformationFieldImage->nu;
outputDeformationFieldImage->datatype = deformationField->datatype;
outputDeformationFieldImage->nbyper = deformationField->nbyper;
outputDeformationFieldImage->data = (void *)calloc(outputDeformationFieldImage->nvox,
......@@ -778,9 +780,9 @@ int main(int argc, char **argv)
deformationFieldImage->pixdim[6]=deformationFieldImage->dv=1.0;
deformationFieldImage->dim[7]=deformationFieldImage->nw=1;
deformationFieldImage->pixdim[7]=deformationFieldImage->dw=1.0;
deformationFieldImage->nvox=deformationFieldImage->nx*deformationFieldImage->ny
*deformationFieldImage->nz*deformationFieldImage->nt
*deformationFieldImage->nu;
deformationFieldImage->nvox =(size_t)deformationFieldImage->nx*(size_t)deformationFieldImage->ny
*(size_t)deformationFieldImage->nz*(size_t)deformationFieldImage->nt
*(size_t)deformationFieldImage->nu;
deformationFieldImage->datatype = nrr_transformation->datatype;
deformationFieldImage->nbyper = nrr_transformation->nbyper;
deformationFieldImage->data = (void *)calloc(deformationFieldImage->nvox,
......
......@@ -360,11 +360,11 @@ Nrrd *reg_io_nifti2nrrd(nifti_image *niiImage)
// Rescale the nii image intensity if required
if(niiImage->scl_slope!=1 && niiImage->scl_slope!=0){
reg_tools_addSubMulDivValue(niiImage, niiImage,niiImage->scl_slope,2); // *(niiImage->scl_slope)
reg_tools_multiplyValueToImage(niiImage,niiImage,niiImage->scl_slope);
niiImage->scl_slope=1;
}
if(niiImage->scl_inter!=0){
reg_tools_addSubMulDivValue(niiImage, niiImage,niiImage->scl_inter,0); // +(niiImage->scl_inter)
reg_tools_addValueToImage(niiImage,niiImage,niiImage->scl_inter);
niiImage->scl_inter=0;
}
......
......@@ -59,18 +59,35 @@ install(TARGETS ${NAME}
)
install(FILES ${NAME}.h ${NAME}.cpp DESTINATION include COMPONENT Development)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
##BUILD THE GPU LIBRARIES
if(USE_CUDA)
#-----------------------------------------------------------------------------
set(LIST _reg_globalTransformation)
set(LIST ${LIST} _reg_blockMatching)
# set(NAME _reg_blocksize_gpu)
# cuda_add_library(${NAME} ${NAME}.h ${NAME}.cu)
# install(TARGETS ${NAME}
# RUNTIME DESTINATION bin COMPONENT Development
# LIBRARY DESTINATION lib COMPONENT Development
# ARCHIVE DESTINATION lib COMPONENT Development
# )
# install(FILES ${NAME}.h DESTINATION include COMPONENT Development)
#-----------------------------------------------------------------------------
set(NAME _reg_common_gpu)
cuda_add_library(${NAME} ${NAME}.h ${NAME}.cu _reg_blocksize_gpu.h _reg_blocksize_gpu.cu)
install(TARGETS ${NAME}
RUNTIME DESTINATION bin COMPONENT Development
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES ${NAME}.h DESTINATION include COMPONENT Development)
#-----------------------------------------------------------------------------
set(LIST _reg_globalTransformation)
set(LIST ${LIST} _reg_blockMatching)
set(LIST ${LIST} _reg_localTransformation)
set(LIST ${LIST} _reg_mutualinformation)
set(LIST ${LIST} _reg_ssd)
set(LIST ${LIST} _reg_resampling)
set(LIST ${LIST} _reg_tools)
set(LIST ${LIST} _reg_ssd)
set(LIST ${LIST} _reg_resampling)
set(LIST ${LIST} _reg_tools)
set(LIST ${LIST} _reg_optimiser)
foreach(NAME ${LIST})
cuda_add_library(${NAME}_gpu ${NAME}_gpu.h ${NAME}_gpu.cu ${NAME}_kernels.cu)
install(TARGETS ${NAME}_gpu
......@@ -80,26 +97,6 @@ if(USE_CUDA)
)
install(FILES ${NAME}_gpu.h DESTINATION include COMPONENT Development)
endforeach(NAME)
#-----------------------------------------------------------------------------
set(NAME _reg_optimiser)
cuda_add_library(${NAME}_gpu ${NAME}_gpu.h ${NAME}_gpu.cu ${NAME}_kernels.cu)
install(TARGETS ${NAME}_gpu
RUNTIME DESTINATION bin COMPONENT Development
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES ${NAME}_gpu.h DESTINATION include)
#-----------------------------------------------------------------------------
set(NAME _reg_common_gpu)
cuda_add_library(${NAME} ${NAME}.h ${NAME}.cu)
install(TARGETS ${NAME}
RUNTIME DESTINATION bin COMPONENT Development
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES ${NAME}.h DESTINATION include)
#-----------------------------------------------------------------------------
install(FILES _reg_blocksize_gpu.h DESTINATION include COMPONENT Development)
#-----------------------------------------------------------------------------
endif(USE_CUDA)
#-----------------------------------------------------------------------------
......@@ -114,7 +111,7 @@ if(USE_CUDA)
else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
cuda_add_library(${NAME} _reg_base.h _reg_base.cpp ${NAME}.h ${NAME}.cpp ${NAME}_sym.h ${NAME}_sym.cpp ${NAME}2.h ${NAME}2.cpp ${NAME}_gpu.h ${NAME}_gpu.cpp)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(${NAME} _reg_localTransformation _reg_resampling _reg_globalTransformation _reg_KLdivergence _reg_ssd _reg_mutualinformation _reg_lncc _reg_optimiser _reg_tools _reg_ReadWriteImage _reg_optimiser_gpu _reg_localTransformation_gpu _reg_resampling_gpu _reg_globalTransformation_gpu _reg_mutualinformation_gpu _reg_ssd_gpu _reg_tools_gpu _reg_common_gpu)
target_link_libraries(${NAME} _reg_localTransformation _reg_resampling _reg_globalTransformation _reg_KLdivergence _reg_ssd _reg_mutualinformation _reg_lncc _reg_optimiser _reg_tools _reg_ReadWriteImage _reg_optimiser_gpu _reg_localTransformation_gpu _reg_resampling_gpu _reg_globalTransformation_gpu _reg_mutualinformation_gpu _reg_ssd_gpu _reg_tools_gpu _reg_common_gpu)
install(FILES ${NAME}_gpu.h ${NAME}_gpu.cpp DESTINATION include COMPONENT Development)
#-----------------------------------------------------------------------------
else(USE_CUDA)
......
......@@ -19,13 +19,8 @@ double reg_getKLDivergence1(nifti_image *referenceImage,
nifti_image *jacobianDetImg,
int *mask)
{
size_t voxelNumber = referenceImage->nx*referenceImage->ny*referenceImage->nz;
#ifdef _WINDOWS
int voxel;
#else
size_t voxelNumber = (size_t)referenceImage->nx*referenceImage->ny*referenceImage->nz;
size_t voxel;
#endif
DTYPE *refPtr=static_cast<DTYPE *>(referenceImage->data);
DTYPE *warPtr=static_cast<DTYPE *>(warpedImage->data);
......@@ -85,13 +80,13 @@ double reg_getKLDivergence(nifti_image *referenceImage,
// Check that both images are of the same type
if(referenceImage->datatype!=warpedImage->datatype){
fprintf(stderr, "[NiftyReg ERROR] reg_getKLDivergence: both input images are expected to have the same type\n");
exit(1);
reg_exit(1);
}
// If the Jacobian determinant image if define, it checks it has the type of the referenceImage image
if(jacobianDetImg!=NULL){
if(referenceImage->datatype!=jacobianDetImg->datatype){
fprintf(stderr, "[NiftyReg ERROR] reg_getKLDivergence: input images are expected to have the same type\n");
exit(1);
reg_exit(1);
}
}
// Check that both input images have the same size
......@@ -99,7 +94,7 @@ double reg_getKLDivergence(nifti_image *referenceImage,
if(referenceImage->dim[i] != warpedImage->dim[i]){
fprintf(stderr,"[NiftyReg ERROR] reg_getSSD\n");
fprintf(stderr,"[NiftyReg ERROR] Input images are expected to have the same dimension");
exit(1);
reg_exit(1);
}
}
switch(referenceImage->datatype){
......@@ -111,7 +106,7 @@ double reg_getKLDivergence(nifti_image *referenceImage,
break;
default:
fprintf(stderr, "[NiftyReg ERROR] reg_getKLDivergence: unsupported datatype\n");
exit(1);
reg_exit(1);
break;
}
return 0.;
......@@ -126,13 +121,8 @@ void reg_getKLDivergenceVoxelBasedGradient1(nifti_image *referenceImage,
nifti_image *jacobianDetImg,
int *mask)
{
size_t voxelNumber = referenceImage->nx*referenceImage->ny*referenceImage->nz;
#ifdef _WINDOWS