]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
tests : fixed windows build (#426)
authorBorislav Stanimirov <redacted>
Thu, 3 Aug 2023 08:03:24 +0000 (11:03 +0300)
committerGitHub <redacted>
Thu, 3 Aug 2023 08:03:24 +0000 (11:03 +0300)
tests/CMakeLists.txt
tests/test-customop.c

index f5d0160c6fdd1ccdf797bf10e74be9f0af379bc9..6a8ce8fe7fd47583546db680bfa774cd53858506 100644 (file)
@@ -194,6 +194,9 @@ set_property(TEST ${TEST_TARGET} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${TEST_
 set(TEST_TARGET test-mul-mat0)
 add_executable(${TEST_TARGET} ${TEST_TARGET}.c)
 target_link_libraries(${TEST_TARGET} PRIVATE ggml ${GGML_EXTRA_LIBS})
+if (MSVC)
+    target_link_options(${TEST_TARGET} PRIVATE "/STACK: 8388608") # 8MB
+endif()
 target_compile_options(${TEST_TARGET} PRIVATE ${GGML_EXTRA_FLAGS})
 add_test(NAME ${TEST_TARGET} COMMAND $<TARGET_FILE:${TEST_TARGET}>)
 set_property(TEST ${TEST_TARGET} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${TEST_TARGET}.profraw")
@@ -274,6 +277,9 @@ set_property(TEST ${TEST_TARGET} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${TEST_
 set(TEST_TARGET test-pool)
 add_executable(${TEST_TARGET} ${TEST_TARGET}.c)
 target_link_libraries(${TEST_TARGET} PRIVATE ggml)
+if (MSVC)
+    target_link_options(${TEST_TARGET} PRIVATE "/STACK: 8388608") # 8MB
+endif()
 add_test(NAME ${TEST_TARGET} COMMAND $<TARGET_FILE:${TEST_TARGET}>)
 set_property(TEST ${TEST_TARGET} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${TEST_TARGET}.profraw")
 
@@ -298,5 +304,8 @@ endif()
 set(TEST_TARGET test-customop)
 add_executable(${TEST_TARGET} ${TEST_TARGET}.c)
 target_link_libraries(${TEST_TARGET} PRIVATE ggml)
+if (MSVC)
+    target_link_options(${TEST_TARGET} PRIVATE "/STACK: 8388608") # 8MB
+endif()
 add_test(NAME ${TEST_TARGET} COMMAND $<TARGET_FILE:${TEST_TARGET}>)
 set_property(TEST ${TEST_TARGET} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${TEST_TARGET}.profraw")
index b45947518d48b731f622d86ac4d9f26058e748ca..ec261ec83584d67838730aa2db1c2b671a3fb220 100644 (file)
@@ -6,6 +6,7 @@
 
 #if defined(_WIN32)
 #include <windows.h>
+typedef volatile LONG atomic_int;
 static LONG atomic_fetch_add(atomic_int * ptr, LONG inc) {
     return InterlockedExchangeAdd(ptr, inc);
 }
@@ -46,7 +47,7 @@ void custom1(struct ggml_tensor * dst , const struct ggml_tensor * a, int ith, i
     assert(ggml_is_contiguous(a));
 
     // parallelize by elements
-    const int ne = ggml_nelements(dst);
+    const int ne = (int)ggml_nelements(dst);
     const int dr = (ne + nth - 1) / nth;
     const int ie0 = dr * ith;
     const int ie1 = MIN(ie0 + dr, ne);
@@ -70,7 +71,7 @@ void custom2(struct ggml_tensor * dst , const struct ggml_tensor * a, const stru
     float * dst_data = ggml_get_data_f32(dst);
 
     // parallelize by rows
-    const int nr = ggml_nrows(dst);
+    const int nr = (int)ggml_nrows(dst);
     // number of rows per thread
     const int dr = (nr + nth - 1) / nth;
     // row range for this thread
@@ -78,7 +79,7 @@ void custom2(struct ggml_tensor * dst , const struct ggml_tensor * a, const stru
     const int ir1 = MIN(ir0 + dr, nr);
 
     // number of columns
-    const int nc = dst->ne[0];
+    const int nc = (int)dst->ne[0];
 
     // this assumes that the tensors are contiguous
     assert(ggml_is_contiguous(dst));
@@ -112,7 +113,7 @@ void custom3(struct ggml_tensor * dst , const struct ggml_tensor * a, const stru
     assert(ith == 0);
 
     // number of elements
-    const int ne = ggml_nelements(dst);
+    const int ne = (int)ggml_nelements(dst);
 
     // this assumes that the tensors are contiguous
     assert(ggml_is_contiguous(dst));