]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
CUDA: fix build and enable warnings (#494)
authorCebtenzzre <redacted>
Tue, 29 Aug 2023 12:34:59 +0000 (08:34 -0400)
committerGitHub <redacted>
Tue, 29 Aug 2023 12:34:59 +0000 (15:34 +0300)
* cmake : fix CUDA build

-Werror=vla needs to be passed to the host compiler.

* cmake : enable warnings for ggml-cuda.cu

* ggml : fix some unused variable warnings

CMakeLists.txt
src/CMakeLists.txt
src/ggml-cuda.cu
src/ggml.c

index 6589e78bbcdc3b2bdcae7bd6959e7ebc80207056..d31be31659e72053e0a57b1977b2c5e06a612776 100644 (file)
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.0)
+cmake_minimum_required (VERSION 3.3)
 project(ggml VERSION 0.1.0)
 
 set(CMAKE_EXPORT_COMPILE_COMMANDS "on")
@@ -84,7 +84,11 @@ if (GGML_ALL_WARNINGS)
 endif()
 
 if (NOT MSVC)
-    add_compile_options(-Werror=vla)
+    add_compile_options(
+        "$<$<COMPILE_LANGUAGE:C>:-Werror=vla>"
+        "$<$<COMPILE_LANGUAGE:CXX>:-Werror=vla>"
+        "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler;-Werror=vla>"
+    )
 endif()
 
 # dependencies
index 81d041513cd04a278ac4ce9601fa9248409405b7..94c31be6244bc75224e9f6fa543bd94b71582f46 100644 (file)
@@ -1,14 +1,7 @@
 if (GGML_ALL_WARNINGS)
     if (NOT MSVC)
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-            -Wunused                        \
-            -Wextra                         \
-            -Wshadow                        \
-            -Wcast-qual                     \
-            -Wdouble-promotion              \
-            -Wno-unused-function            \
-            -Wmissing-prototypes            \
-        ")
+        add_compile_options(-Wunused -Wextra -Wcast-qual -Wdouble-promotion)
+        add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wshadow;-Wno-unused-function;-Wmissing-prototypes>")
     else()
         # todo : windows
     endif()
index 5fd62563022967f0a02dccd1361aec23617fb11d..391e63181c0fc688e686eef2434a75ec7b05674a 100644 (file)
@@ -5721,6 +5721,7 @@ inline void ggml_cuda_op_alibi(
     (void) src1;
     (void) src0_ddq_i;
     (void) src1_ddf_i;
+    (void) i02;
     (void) i1;
 }
 
index b199bb1a6a3e31c4d92ab5937025f17826f0964b..fb534c4cb59e464f9eb887ce5e3588c7ad32786d 100644 (file)
@@ -1292,6 +1292,7 @@ static void quantize_row_q8_0(const float * restrict x, void * restrict vy, int
 #endif
     }
 #else
+    (void)nb;
     // scalar
     quantize_row_q8_0_reference(x, y, k);
 #endif
@@ -1510,6 +1511,7 @@ static void quantize_row_q8_1(const float * restrict x, void * restrict vy, int
 #endif
     }
 #else
+    (void)nb;
     // scalar
     quantize_row_q8_1_reference(x, y, k);
 #endif