From 920d6d0ab648f55410644c6aaf52d422e97c7761 Mon Sep 17 00:00:00 2001
From: NAUD Maxence <maxence.naud@cea.fr>
Date: Tue, 28 Jan 2025 16:03:07 +0000
Subject: [PATCH 1/4] Enforce C++-14 in 'CMakeLists.txt'

---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8d5d22..243cc75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,9 @@
 # CMake >= 3.18 is required for good support of FindCUDAToolkit
 cmake_minimum_required(VERSION 3.18)
-set(CXX_STANDARD 14)
+
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS  OFF)
 
 file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
 
-- 
GitLab


From f0858122765f7505585a8c0252b13e83fd127de3 Mon Sep 17 00:00:00 2001
From: NAUD Maxence <maxence.naud@cea.fr>
Date: Tue, 28 Jan 2025 16:05:48 +0000
Subject: [PATCH 2/4] Change Python minimum version 3.7 -> 3.8

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 4946af1..9abb470 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ description="CUDA implementations of the operators of aidge framework"
 dependencies = [
     "numpy",
 ]
-requires-python = ">= 3.7"
+requires-python = ">= 3.8"
 readme = "README.md"
 license = { file = "LICENSE" }
 classifiers = [
-- 
GitLab


From 34594a2fe956337de193d774d6f1bcead2a3704c Mon Sep 17 00:00:00 2001
From: NAUD Maxence <maxence.naud@cea.fr>
Date: Tue, 28 Jan 2025 16:08:12 +0000
Subject: [PATCH 3/4] UPD: 'setup.py' to access compilation options from
 environment variables set by 'setup.sh'

---
 setup.py | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/setup.py b/setup.py
index 706fc53..c72553a 100644
--- a/setup.py
+++ b/setup.py
@@ -37,6 +37,7 @@ class CMakeBuild(build_ext):
         # This lists the number of processors available on the machine
         # The compilation will use half of them
         max_jobs = str(ceil(multiprocessing.cpu_count() / 2))
+        max_jobs = os.environ.get("AIDGE_NB_PROC", max_jobs)
 
         cwd = pathlib.Path().absolute()
 
@@ -50,33 +51,41 @@ class CMakeBuild(build_ext):
 
         os.chdir(str(build_temp))
 
-        compile_type = (
-            "Release"
-            if "AIDGE_PYTHON_BUILD_TYPE" not in os.environ
-            else os.environ["AIDGE_PYTHON_BUILD_TYPE"]
-        )
-
         install_path = (
             os.path.join(sys.prefix, "lib", "libAidge")
             if "AIDGE_INSTALL" not in os.environ
             else os.environ["AIDGE_INSTALL"]
         )
 
+        # Read environment variables for CMake options
+        c_compiler = os.environ.get("AIDGE_C_COMPILER", "gcc")
+        cxx_compiler = os.environ.get("AIDGE_CXX_COMPILER", "g++")
+        build_type = os.environ.get("AIDGE_BUILD_TYPE", "Release")
+        asan = os.environ.get("AIDGE_ASAN", "OFF")
+        with_cuda = os.environ.get("AIDGE_WITH_CUDA", "OFF")
+
         # using ninja as default build system to build faster and with the same compiler as on windows
-        build_gen = (
-            ["-G", os.environ["AIDGE_BUILD_GEN"]]
-            if "AIDGE_BUILD_GEN" in os.environ
+        build_gen = os.environ.get("AIDGE_BUILD_GEN", "")
+        build_gen_opts = (
+            ["-G", build_gen]
+            if build_gen
             else []
         )
-        
+
+        test_onoff = os.environ.get("AIDGE_BUILD_TEST", "OFF")
+
         self.spawn(
             [
                 "cmake",
                 *build_gen,
                 str(cwd),
-                "-DTEST=OFF",
+                f"-DTEST={test_onoff}",
                 f"-DCMAKE_INSTALL_PREFIX:PATH={install_path}",
-                f"-DCMAKE_BUILD_TYPE={compile_type}",
+                f"-DCMAKE_BUILD_TYPE={build_type}",
+                f"-DCMAKE_C_COMPILER={c_compiler}",
+                f"-DCMAKE_CXX_COMPILER={cxx_compiler}",
+                f"-DENABLE_ASAN={asan}",
+                f"-DCUDA={with_cuda}",
                 "-DPYBIND=ON",
                 "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
                 "-DCOVERAGE=OFF",
@@ -86,9 +95,9 @@ class CMakeBuild(build_ext):
 
         if not self.dry_run:
             self.spawn(
-                ["cmake", "--build", ".", "--config", compile_type, "-j", max_jobs]
+                ["cmake", "--build", ".", "--config", build_type, "-j", max_jobs]
             )
-            self.spawn(["cmake", "--install", ".", "--config", compile_type])
+            self.spawn(["cmake", "--install", ".", "--config", build_type])
         os.chdir(str(cwd))
 
         aidge_package = build_lib / (get_project_name())
-- 
GitLab


From 59629a5128e3bbb5db8bc16ea39fe0e091b2036d Mon Sep 17 00:00:00 2001
From: NAUD Maxence <maxence.naud@cea.fr>
Date: Tue, 28 Jan 2025 16:11:24 +0000
Subject: [PATCH 4/4] Change 'fmt::print' calls for 'Log::info' in some tests

---
 unit_tests/Test_AvgPoolingImpl.cpp           |  4 ++--
 unit_tests/Test_GlobalAveragePoolingImpl.cpp |  4 ++--
 unit_tests/Test_MaxPoolingImpl.cpp           |  4 ++--
 unit_tests/Test_PowImpl.cpp                  | 12 ++++++------
 unit_tests/Test_ReLUImpl.cpp                 |  4 ++--
 unit_tests/Test_ReshapeImpl.cpp              |  4 ++--
 unit_tests/Test_SqrtImpl.cpp                 |  4 ++--
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/unit_tests/Test_AvgPoolingImpl.cpp b/unit_tests/Test_AvgPoolingImpl.cpp
index 4ad761a..b658ee7 100644
--- a/unit_tests/Test_AvgPoolingImpl.cpp
+++ b/unit_tests/Test_AvgPoolingImpl.cpp
@@ -236,8 +236,8 @@ TEST_CASE("[gpu/operator] AvgPooling(forward)", "[AvgPooling][GPU]")
             delete[] array0;
             cudaFree(array0_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
     }
 }
 
diff --git a/unit_tests/Test_GlobalAveragePoolingImpl.cpp b/unit_tests/Test_GlobalAveragePoolingImpl.cpp
index fb67fa5..5c13f45 100644
--- a/unit_tests/Test_GlobalAveragePoolingImpl.cpp
+++ b/unit_tests/Test_GlobalAveragePoolingImpl.cpp
@@ -178,8 +178,8 @@ TEST_CASE("[gpu/operator] GlobalAveragePooling",
             delete[] array0;
             cudaFree(array0_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
     }
 }
 } // namespace Aidge
diff --git a/unit_tests/Test_MaxPoolingImpl.cpp b/unit_tests/Test_MaxPoolingImpl.cpp
index e6fcc80..0474a70 100644
--- a/unit_tests/Test_MaxPoolingImpl.cpp
+++ b/unit_tests/Test_MaxPoolingImpl.cpp
@@ -193,7 +193,7 @@ TEST_CASE("[gpu/operator] MaxPooling(forward)", "[MaxPooling][GPU]") {
             delete[] array0;
             cudaFree(array0_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
     }
 }
\ No newline at end of file
diff --git a/unit_tests/Test_PowImpl.cpp b/unit_tests/Test_PowImpl.cpp
index 60629ca..78be1ca 100644
--- a/unit_tests/Test_PowImpl.cpp
+++ b/unit_tests/Test_PowImpl.cpp
@@ -148,8 +148,8 @@ TEST_CASE("[gpu/operator] Pow", "[Pow][GPU]") {
                 cudaFree(array0_d);
                 cudaFree(array1_d);
             }
-            fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-            fmt::print("INFO: Total time: {}μs\n", duration.count());
+            Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+            Log::info("Total time: {}μs\n", duration.count());
         }
 
         SECTION("+1-D Tensor / +1-D Tensor - broadcasting") {
@@ -256,8 +256,8 @@ TEST_CASE("[gpu/operator] Pow", "[Pow][GPU]") {
                 const std::size_t nb_elements = std::accumulate(dimsOut.cbegin(), dimsOut.cend(), std::size_t(1), std::multiplies<std::size_t>());
                 number_of_operation += nb_elements;
             }
-            fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-            fmt::print("INFO: Total time: {}μs\n", duration.count());
+            Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+            Log::info("Total time: {}μs\n", duration.count());
         }
         SECTION("+1-D Tensor / 1-D Tensor") {
             // Create Pow Operator
@@ -361,8 +361,8 @@ TEST_CASE("[gpu/operator] Pow", "[Pow][GPU]") {
                 const std::size_t nb_elements = std::accumulate(dimsOut.cbegin(), dimsOut.cend(), std::size_t(1), std::multiplies<std::size_t>());
                 number_of_operation += nb_elements;
             }
-            fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-            fmt::print("INFO: Total time: {}μs\n", duration.count());
+            Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+            Log::info("Total time: {}μs\n", duration.count());
         }
     }
 }
diff --git a/unit_tests/Test_ReLUImpl.cpp b/unit_tests/Test_ReLUImpl.cpp
index 58a3953..d55ccd1 100644
--- a/unit_tests/Test_ReLUImpl.cpp
+++ b/unit_tests/Test_ReLUImpl.cpp
@@ -174,7 +174,7 @@ TEST_CASE("[gpu/operator] ReLU(forward)", "[ReLU][GPU]") {
             delete[] input_h;
             cudaFree(input_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
     }
 }
diff --git a/unit_tests/Test_ReshapeImpl.cpp b/unit_tests/Test_ReshapeImpl.cpp
index 60828ad..d62fc46 100644
--- a/unit_tests/Test_ReshapeImpl.cpp
+++ b/unit_tests/Test_ReshapeImpl.cpp
@@ -185,8 +185,8 @@ TEST_CASE("[gpu/operator] Reshape(forward)") {
             delete[] array0;
             cudaFree(array0_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
     }
 }
 
diff --git a/unit_tests/Test_SqrtImpl.cpp b/unit_tests/Test_SqrtImpl.cpp
index c381b69..934cb09 100644
--- a/unit_tests/Test_SqrtImpl.cpp
+++ b/unit_tests/Test_SqrtImpl.cpp
@@ -116,7 +116,7 @@ constexpr std::uint16_t NBTRIALS = 10;
             delete[] array0;
             cudaFree(array0_d);
         }
-        fmt::print("INFO: Number of elements over time spent: {}\n", number_of_operation / duration.count());
-        fmt::print("INFO: Total time: {}μs\n", duration.count());
+        Log::info("Number of elements over time spent: {}\n", number_of_operation / duration.count());
+        Log::info("Total time: {}μs\n", duration.count());
 }
 } // namespace Aidge
-- 
GitLab