Simplify extern "C" expressions

This commit is contained in:
augustin64 2023-02-15 11:22:51 +01:00
parent 20508558ba
commit a9262cacc1
5 changed files with 21 additions and 63 deletions

View File

@ -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 $@

View File

@ -70,8 +70,7 @@ 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);
@ -79,5 +78,3 @@ void make_convolution(Kernel_cnn* kernel, float*** input, float*** output, int o
make_convolution_device(kernel, input, output, output_dim);
#endif
}
}

View File

@ -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

View File

@ -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

View File

@ -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