changeset 2069:5956d7357098 deep-learning

macro ORTHANC_HAS_WASM_SIMD has to be manually defined
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 May 2023 17:00:17 +0200
parents 22a83fb9dd23
children 82dbe2729b69
files Applications/Samples/WebAssembly/CMakeLists.txt Applications/StoneWebViewer/WebAssembly/CMakeLists.txt Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt OrthancStone/Resources/WebAssemblySharedLibrary/CMakeLists.txt OrthancStone/Resources/WebAssemblyUnitTests/CMakeLists.txt OrthancStone/Sources/Toolbox/SimdIncludes.h
diffstat 6 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/WebAssembly/CMakeLists.txt	Wed May 17 17:30:52 2023 +0200
+++ b/Applications/Samples/WebAssembly/CMakeLists.txt	Fri May 19 17:00:17 2023 +0200
@@ -52,6 +52,7 @@
 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
 add_definitions(
   -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
+  -DORTHANC_HAS_WASM_SIMD=0
   -DORTHANC_WEBGL2_HEAP_COMPAT=0
 )
 
--- a/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt	Wed May 17 17:30:52 2023 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt	Fri May 19 17:00:17 2023 +0200
@@ -44,6 +44,7 @@
 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
 add_definitions(
   -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
+  -DORTHANC_HAS_WASM_SIMD=0
   -DORTHANC_WEBGL2_HEAP_COMPAT=0
 )
 
--- a/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt	Wed May 17 17:30:52 2023 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneModule/CMakeLists.txt	Fri May 19 17:00:17 2023 +0200
@@ -54,6 +54,7 @@
 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
 add_definitions(
   -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
+  -DORTHANC_HAS_WASM_SIMD=0
   -DORTHANC_WEBGL2_HEAP_COMPAT=0
 )
 
--- a/OrthancStone/Resources/WebAssemblySharedLibrary/CMakeLists.txt	Wed May 17 17:30:52 2023 +0200
+++ b/OrthancStone/Resources/WebAssemblySharedLibrary/CMakeLists.txt	Fri May 19 17:00:17 2023 +0200
@@ -54,6 +54,7 @@
 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
 add_definitions(
   -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
+  -DORTHANC_HAS_WASM_SIMD=0
   -DORTHANC_WEBGL2_HEAP_COMPAT=0
 )
 
--- a/OrthancStone/Resources/WebAssemblyUnitTests/CMakeLists.txt	Wed May 17 17:30:52 2023 +0200
+++ b/OrthancStone/Resources/WebAssemblyUnitTests/CMakeLists.txt	Fri May 19 17:00:17 2023 +0200
@@ -47,6 +47,7 @@
 add_definitions(
   -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
   -DORTHANC_BUILD_UNIT_TESTS=1
+  -DORTHANC_HAS_WASM_SIMD=0
   -DORTHANC_WEBGL2_HEAP_COMPAT=0
   )
 
--- a/OrthancStone/Sources/Toolbox/SimdIncludes.h	Wed May 17 17:30:52 2023 +0200
+++ b/OrthancStone/Sources/Toolbox/SimdIncludes.h	Fri May 19 17:00:17 2023 +0200
@@ -41,10 +41,19 @@
 #  define ORTHANC_HAS_WASM_SIMD     0
 #  define ORTHANC_MEMORY_ALIGNMENT  16
 #elif defined(__EMSCRIPTEN__)
+#  if !defined(ORTHANC_HAS_WASM_SIMD)
+#    error ORTHANC_HAS_WASM_SIMD must be defined to use this file
+#  endif
 #  define ORTHANC_HAS_AVX2          0
 #  define ORTHANC_HAS_SSE2          0
-#  define ORTHANC_HAS_WASM_SIMD     1
-#  define ORTHANC_MEMORY_ALIGNMENT  16
+#  if ORTHANC_HAS_WASM_SIMD == 1
+//   Setting macro "ORTHANC_HAS_WASM_SIMD" to "1" means that
+//   "-msimd128" has been provided to Emscripten (there doesn't seem
+//   to exist a predefined macro to automatically check this)
+#    define ORTHANC_MEMORY_ALIGNMENT  16
+#  else
+#    define ORTHANC_MEMORY_ALIGNMENT  8
+#  endif
 #elif defined(_MSC_VER)
 #  if _M_IX86_FP >= 2   // https://stackoverflow.com/a/18563988
 #    define ORTHANC_HAS_AVX2          0