mirror of
https://github.com/augustin64/projet-tipe
synced 2025-02-02 19:39:39 +01:00
Simplify extern "C"
expressions
This commit is contained in:
parent
20508558ba
commit
a9262cacc1
14
Makefile
14
Makefile
@ -96,19 +96,19 @@ ifdef NVCC_INSTALLED
|
|||||||
$(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \
|
$(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \
|
||||||
$(BUILDDIR)/cnn_train.cuda.o \
|
$(BUILDDIR)/cnn_train.cuda.o \
|
||||||
$(BUILDDIR)/cnn_test_network.cuda.o \
|
$(BUILDDIR)/cnn_test_network.cuda.o \
|
||||||
$(BUILDDIR)/cnn_cnn.o \
|
$(BUILDDIR)/cnn_cnn.cuda.o \
|
||||||
$(BUILDDIR)/cnn_creation.cuda.o \
|
$(BUILDDIR)/cnn_creation.cuda.o \
|
||||||
$(BUILDDIR)/cnn_initialisation.o \
|
$(BUILDDIR)/cnn_initialisation.cuda.o \
|
||||||
$(BUILDDIR)/cnn_make.o \
|
$(BUILDDIR)/cnn_cuda_make.o \
|
||||||
$(BUILDDIR)/cnn_neuron_io.cuda.o \
|
$(BUILDDIR)/cnn_neuron_io.cuda.o \
|
||||||
$(BUILDDIR)/cnn_function.o \
|
$(BUILDDIR)/cnn_function.cuda.o \
|
||||||
$(BUILDDIR)/cnn_utils.cuda.o \
|
$(BUILDDIR)/cnn_utils.cuda.o \
|
||||||
$(BUILDDIR)/cnn_update.o \
|
$(BUILDDIR)/cnn_update.cuda.o \
|
||||||
$(BUILDDIR)/cnn_free.cuda.o \
|
$(BUILDDIR)/cnn_free.cuda.o \
|
||||||
$(BUILDDIR)/cnn_jpeg.cuda.o \
|
$(BUILDDIR)/cnn_jpeg.cuda.o \
|
||||||
$(BUILDDIR)/cnn_cuda_convolution.o \
|
$(BUILDDIR)/cnn_cuda_convolution.o \
|
||||||
$(BUILDDIR)/cnn_backpropagation.o \
|
$(BUILDDIR)/cnn_backpropagation.cuda.o \
|
||||||
$(BUILDDIR)/colors.o \
|
$(BUILDDIR)/colors.cuda.o \
|
||||||
$(BUILDDIR)/mnist.cuda.o \
|
$(BUILDDIR)/mnist.cuda.o \
|
||||||
$(BUILDDIR)/cuda_utils.o
|
$(BUILDDIR)/cuda_utils.o
|
||||||
$(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@
|
$(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@
|
||||||
|
@ -70,8 +70,7 @@ void make_convolution_device(Kernel_cnn* kernel, float*** input, float*** output
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
|
||||||
void make_convolution(Kernel_cnn* kernel, float*** input, float*** output, int output_dim) {
|
void make_convolution(Kernel_cnn* kernel, float*** input, float*** output, int output_dim) {
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
make_convolution_cpu(kernel, input, output, output_dim);
|
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);
|
make_convolution_device(kernel, input, output, output_dim);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
@ -34,27 +34,18 @@ int i_div_up(int a, int b);
|
|||||||
* Vérification de la compatibilité CUDA
|
* Vérification de la compatibilité CUDA
|
||||||
*/
|
*/
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
bool check_cuda_compatibility();
|
bool check_cuda_compatibility();
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void* nalloc(size_t sz);
|
void* nalloc(size_t sz);
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void gree(void* ptr);
|
void gree(void* ptr);
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
25
src/utils.c
25
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__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
bool check_cuda_compatibility() {
|
bool check_cuda_compatibility() {
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
@ -43,52 +43,37 @@ bool check_cuda_compatibility() {
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_CUDA
|
#ifndef USE_CUDA
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void* nalloc(size_t sz) {
|
void* nalloc(size_t sz) {
|
||||||
void* ptr = malloc(sz);
|
void* ptr = malloc(sz);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void gree(void* ptr) {
|
void gree(void* ptr) {
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void* nalloc(size_t sz) {
|
void* nalloc(size_t sz) {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
cudaMallocManaged(&ptr, sz, cudaMemAttachHost);
|
cudaMallocManaged(&ptr, sz, cudaMemAttachHost);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void gree(void* ptr) {
|
void gree(void* ptr) {
|
||||||
cudaFree(ptr);
|
cudaFree(ptr);
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
25
src/utils.cu
25
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__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
bool check_cuda_compatibility() {
|
bool check_cuda_compatibility() {
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
@ -43,52 +43,37 @@ bool check_cuda_compatibility() {
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_CUDA
|
#ifndef USE_CUDA
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void* nalloc(size_t sz) {
|
void* nalloc(size_t sz) {
|
||||||
void* ptr = malloc(sz);
|
void* ptr = malloc(sz);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void gree(void* ptr) {
|
void gree(void* ptr) {
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void* nalloc(size_t sz) {
|
void* nalloc(size_t sz) {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
cudaMallocManaged(&ptr, sz, cudaMemAttachHost);
|
cudaMallocManaged(&ptr, sz, cudaMemAttachHost);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
void gree(void* ptr) {
|
void gree(void* ptr) {
|
||||||
cudaFree(ptr);
|
cudaFree(ptr);
|
||||||
}
|
}
|
||||||
#ifdef __CUDACC__
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user