Skip to content

Commit a0dad9f

Browse files
externalize standard calls for cuda
1 parent 9ba6224 commit a0dad9f

File tree

4 files changed

+65
-52
lines changed

4 files changed

+65
-52
lines changed

src/convolution3Dfft.cu

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -539,40 +539,3 @@ void convolution3DfftCUDAInPlaceSaveMemory(imageType* im,int* imDim,imageType* k
539539
540540
}
541541
*/
542-
//==============================================
543-
int getCUDAcomputeCapabilityMajorVersion(int devCUDA)
544-
{
545-
int major = 0, minor = 0;
546-
cuDeviceComputeCapability ( &major, &minor,devCUDA);
547-
548-
return major;
549-
}
550-
int getCUDAcomputeCapabilityMinorVersion(int devCUDA)
551-
{
552-
int major = 0, minor = 0;
553-
cuDeviceComputeCapability ( &major, &minor,devCUDA);
554-
555-
return minor;
556-
}
557-
558-
int getNumDevicesCUDA()
559-
{
560-
int count = 0;
561-
HANDLE_ERROR(cudaGetDeviceCount ( &count ));
562-
return count;
563-
}
564-
void getNameDeviceCUDA(int devCUDA, char* name)
565-
{
566-
cudaDeviceProp prop;
567-
HANDLE_ERROR( cudaGetDeviceProperties(&prop, devCUDA));
568-
569-
memcpy(name,prop.name,sizeof(char)*256);
570-
}
571-
long long int getMemDeviceCUDA(int devCUDA)
572-
{
573-
cudaDeviceProp prop;
574-
HANDLE_ERROR( cudaGetDeviceProperties(&prop, devCUDA));
575-
return ((long long int)prop.totalGlobalMem);
576-
}
577-
578-

src/convolution3Dfft.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef __CONVOLUTION_3D_FFT_H__
22
#define __CONVOLUTION_3D_FFT_H__
33

4+
#include "standardCUDAfunctions.h"
45

56
//define constants
67
typedef float imageType;//the kind sof images we are working with (you will need to recompile to work with other types)
@@ -45,19 +46,4 @@ WARNING: If imSize > 5*kernelSize the maximum relative error in the convolution
4546
*/
4647
//extern "C" __declspec(dllexport) void convolution3DfftCUDAInPlaceSaveMemory(imageType* im,int* imDim,imageType* kernel,int* kernelDim,int devCUDA);
4748

48-
//----------------------------------functions to decide whhich GPU to use-------------------------------
49-
50-
/*
51-
*/
52-
53-
extern "C" int getCUDAcomputeCapabilityMinorVersion(int devCUDA);
54-
extern "C" int getCUDAcomputeCapabilityMajorVersion(int devCUDA);
55-
56-
/*
57-
*/
58-
extern "C" int getNumDevicesCUDA();
59-
//extern "C" __declspec(dllexport) char* getNameDeviceCUDA(int devCUDA);
60-
extern "C" void getNameDeviceCUDA(int devCUDA, char *name);
61-
extern "C" long long int getMemDeviceCUDA(int devCUDA);
62-
6349
#endif //__CONVOLUTION_3D_FFT_H__

src/standardCUDAfunctions.cu

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* standardCUDAfunctions.cu
3+
*
4+
* Created on: Jul 24, 2014
5+
* Author: preibisch
6+
*/
7+
#include "book.h"
8+
#include "cuda.h"
9+
#include "standardCUDAfunctions.h"
10+
11+
//==============================================
12+
int getCUDAcomputeCapabilityMajorVersion(int devCUDA)
13+
{
14+
int major = 0, minor = 0;
15+
cuDeviceComputeCapability(&major, &minor,devCUDA);
16+
17+
return major;
18+
}
19+
int getCUDAcomputeCapabilityMinorVersion(int devCUDA)
20+
{
21+
int major = 0, minor = 0;
22+
cuDeviceComputeCapability(&major, &minor,devCUDA);
23+
24+
return minor;
25+
}
26+
27+
int getNumDevicesCUDA()
28+
{
29+
int count = 0;
30+
HANDLE_ERROR(cudaGetDeviceCount ( &count ));
31+
return count;
32+
}
33+
void getNameDeviceCUDA(int devCUDA, char* name)
34+
{
35+
cudaDeviceProp prop;
36+
HANDLE_ERROR( cudaGetDeviceProperties(&prop, devCUDA));
37+
38+
memcpy(name,prop.name,sizeof(char)*256);
39+
}
40+
long long int getMemDeviceCUDA(int devCUDA)
41+
{
42+
cudaDeviceProp prop;
43+
HANDLE_ERROR( cudaGetDeviceProperties(&prop, devCUDA));
44+
return ((long long int)prop.totalGlobalMem);
45+
}

src/standardCUDAfunctions.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* standardCUDAfunctions.h
3+
*
4+
* Created on: Jul 24, 2014
5+
* Author: preibisch
6+
*/
7+
8+
#ifndef STANDARDCUDAFUNCTIONS_H_
9+
#define STANDARDCUDAFUNCTIONS_H_
10+
11+
//----------------------------------functions to decide whhich GPU to use-------------------------------
12+
13+
extern "C" int getCUDAcomputeCapabilityMinorVersion(int devCUDA);
14+
extern "C" int getCUDAcomputeCapabilityMajorVersion(int devCUDA);
15+
extern "C" int getNumDevicesCUDA();
16+
extern "C" void getNameDeviceCUDA(int devCUDA, char *name);
17+
extern "C" long long int getMemDeviceCUDA(int devCUDA);
18+
19+
#endif /* STANDARDCUDAFUNCTIONS_H_ */

0 commit comments

Comments
 (0)