From 693dee581ec01905b2990071cdf226e292b7f009 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Fri, 12 May 2023 16:17:47 +0200 Subject: [PATCH] Move 'min' and 'max' definition to commons/utils --- src/cnn/backpropagation.c | 10 ---------- src/cnn/backpropagation.cu | 10 ---------- src/cnn/include/backpropagation.h | 10 ---------- src/common/include/utils.h | 14 ++++++++++++++ src/common/utils.c | 11 +++++++++++ src/common/utils.cu | 11 +++++++++++ 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/cnn/backpropagation.c b/src/cnn/backpropagation.c index e444540..397720a 100644 --- a/src/cnn/backpropagation.c +++ b/src/cnn/backpropagation.c @@ -8,16 +8,6 @@ #include "include/config.h" -#ifndef __CUDACC__ -int min(int a, int b) { - return a b ? a : b; -} -#endif - /* * Softmax backward MSE */ diff --git a/src/cnn/backpropagation.cu b/src/cnn/backpropagation.cu index e444540..397720a 100644 --- a/src/cnn/backpropagation.cu +++ b/src/cnn/backpropagation.cu @@ -8,16 +8,6 @@ #include "include/config.h" -#ifndef __CUDACC__ -int min(int a, int b) { - return a b ? a : b; -} -#endif - /* * Softmax backward MSE */ diff --git a/src/cnn/include/backpropagation.h b/src/cnn/include/backpropagation.h index 4656e18..0786e5f 100644 --- a/src/cnn/include/backpropagation.h +++ b/src/cnn/include/backpropagation.h @@ -4,16 +4,6 @@ #ifndef DEF_BACKPROPAGATION_H #define DEF_BACKPROPAGATION_H -/* -* Renvoie la valeur minimale entre a et b -*/ -int min(int a, int b); - -/* -* Renvoie la valeur maximale entre a et b -*/ -int max(int a, int b); - #ifdef __CUDACC__ extern "C" diff --git a/src/common/include/utils.h b/src/common/include/utils.h index b18d59c..7c0e8f9 100644 --- a/src/common/include/utils.h +++ b/src/common/include/utils.h @@ -25,6 +25,20 @@ inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=t } #endif + +#ifndef __CUDACC__ +/* +* Renvoie la valeur minimale entre a et b +*/ +int min(int a, int b); + +/* +* Renvoie la valeur maximale entre a et b +*/ +int max(int a, int b); +#endif + + /* * Partie entière supérieure de a/b */ diff --git a/src/common/utils.c b/src/common/utils.c index f8073eb..03ee100 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -16,6 +16,17 @@ #define BLOCKSIZE_z 8 +#ifndef __CUDACC__ +int min(int a, int b) { + return a b ? a : b; +} +#endif + + int i_div_up(int a, int b) { // Partie entière supérieure de a/b return ((a % b) != 0) ? (a / b + 1) : (a / b); } diff --git a/src/common/utils.cu b/src/common/utils.cu index f8073eb..03ee100 100644 --- a/src/common/utils.cu +++ b/src/common/utils.cu @@ -16,6 +16,17 @@ #define BLOCKSIZE_z 8 +#ifndef __CUDACC__ +int min(int a, int b) { + return a b ? a : b; +} +#endif + + int i_div_up(int a, int b) { // Partie entière supérieure de a/b return ((a % b) != 0) ? (a / b + 1) : (a / b); }