diff --git a/Makefile b/Makefile index f2fb2db..b3e038b 100644 --- a/Makefile +++ b/Makefile @@ -96,19 +96,19 @@ ifdef NVCC_INSTALLED $(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \ $(BUILDDIR)/cnn_train.cuda.o \ $(BUILDDIR)/cnn_test_network.cuda.o \ - $(BUILDDIR)/cnn_cnn.o \ + $(BUILDDIR)/cnn_cnn.cuda.o \ $(BUILDDIR)/cnn_creation.cuda.o \ - $(BUILDDIR)/cnn_initialisation.o \ - $(BUILDDIR)/cnn_make.o \ + $(BUILDDIR)/cnn_initialisation.cuda.o \ + $(BUILDDIR)/cnn_cuda_make.o \ $(BUILDDIR)/cnn_neuron_io.cuda.o \ - $(BUILDDIR)/cnn_function.o \ + $(BUILDDIR)/cnn_function.cuda.o \ $(BUILDDIR)/cnn_utils.cuda.o \ - $(BUILDDIR)/cnn_update.o \ + $(BUILDDIR)/cnn_update.cuda.o \ $(BUILDDIR)/cnn_free.cuda.o \ $(BUILDDIR)/cnn_jpeg.cuda.o \ $(BUILDDIR)/cnn_cuda_convolution.o \ - $(BUILDDIR)/cnn_backpropagation.o \ - $(BUILDDIR)/colors.o \ + $(BUILDDIR)/cnn_backpropagation.cuda.o \ + $(BUILDDIR)/colors.cuda.o \ $(BUILDDIR)/mnist.cuda.o \ $(BUILDDIR)/cuda_utils.o $(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@ diff --git a/src/cnn/convolution.cu b/src/cnn/convolution.cu index e3f4dc2..edd3fa5 100644 --- a/src/cnn/convolution.cu +++ b/src/cnn/convolution.cu @@ -70,14 +70,11 @@ void make_convolution_device(Kernel_cnn* kernel, float*** input, float*** output } #endif -extern "C" { - +extern "C" void make_convolution(Kernel_cnn* kernel, float*** input, float*** output, int output_dim) { #ifndef __CUDACC__ make_convolution_cpu(kernel, input, output, output_dim); #else make_convolution_device(kernel, input, output, output_dim); #endif -} - } \ No newline at end of file diff --git a/src/include/utils.h b/src/include/utils.h index 5bc7ecc..96a78b4 100644 --- a/src/include/utils.h +++ b/src/include/utils.h @@ -34,27 +34,18 @@ int i_div_up(int a, int b); * Vérification de la compatibilité CUDA */ #ifdef __CUDACC__ -extern "C" { +extern "C" #endif bool check_cuda_compatibility(); -#ifdef __CUDACC__ -} -#endif #ifdef __CUDACC__ -extern "C" { +extern "C" #endif void* nalloc(size_t sz); -#ifdef __CUDACC__ -} -#endif #ifdef __CUDACC__ -extern "C" { +extern "C" #endif void gree(void* ptr); -#ifdef __CUDACC__ -} -#endif #endif \ No newline at end of file diff --git a/src/utils.c b/src/utils.c index 5868153..23f5847 100644 --- a/src/utils.c +++ b/src/utils.c @@ -15,7 +15,7 @@ int i_div_up(int a, int b) { // Partie entière supérieure de a/b } #ifdef __CUDACC__ -extern "C" { +extern "C" #endif bool check_cuda_compatibility() { #ifdef __CUDACC__ @@ -43,52 +43,37 @@ bool check_cuda_compatibility() { return false; #endif } -#ifdef __CUDACC__ -} -#endif #ifndef USE_CUDA #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void* nalloc(size_t sz) { void* ptr = malloc(sz); return ptr; } - #ifdef __CUDACC__ - } - #endif #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void gree(void* ptr) { free(ptr); } - #ifdef __CUDACC__ - } - #endif #else #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void* nalloc(size_t sz) { void* ptr; cudaMallocManaged(&ptr, sz, cudaMemAttachHost); return ptr; } - #ifdef __CUDACC__ - } - #endif #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void gree(void* ptr) { cudaFree(ptr); } - #ifdef __CUDACC__ - } - #endif #endif diff --git a/src/utils.cu b/src/utils.cu index 5868153..23f5847 100644 --- a/src/utils.cu +++ b/src/utils.cu @@ -15,7 +15,7 @@ int i_div_up(int a, int b) { // Partie entière supérieure de a/b } #ifdef __CUDACC__ -extern "C" { +extern "C" #endif bool check_cuda_compatibility() { #ifdef __CUDACC__ @@ -43,52 +43,37 @@ bool check_cuda_compatibility() { return false; #endif } -#ifdef __CUDACC__ -} -#endif #ifndef USE_CUDA #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void* nalloc(size_t sz) { void* ptr = malloc(sz); return ptr; } - #ifdef __CUDACC__ - } - #endif #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void gree(void* ptr) { free(ptr); } - #ifdef __CUDACC__ - } - #endif #else #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void* nalloc(size_t sz) { void* ptr; cudaMallocManaged(&ptr, sz, cudaMemAttachHost); return ptr; } - #ifdef __CUDACC__ - } - #endif #ifdef __CUDACC__ - extern "C" { + extern "C" #endif void gree(void* ptr) { cudaFree(ptr); } - #ifdef __CUDACC__ - } - #endif #endif