summaryrefslogtreecommitdiffstats
path: root/Tests/ISPC/ChainedStaticLibraries
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-07-28 18:52:36 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-09-04 12:37:07 (GMT)
commita020787a9b7ede3aa490345bd446e469fb1713d2 (patch)
treef96ef2b1d84515fda4288ffaf39e9abfb8c9cc1a /Tests/ISPC/ChainedStaticLibraries
parent5a1750017e65727660167ae1953746a3fd3d2c7b (diff)
downloadCMake-a020787a9b7ede3aa490345bd446e469fb1713d2.zip
CMake-a020787a9b7ede3aa490345bd446e469fb1713d2.tar.gz
CMake-a020787a9b7ede3aa490345bd446e469fb1713d2.tar.bz2
ISPC: Support generation for multiple instruction sets
Diffstat (limited to 'Tests/ISPC/ChainedStaticLibraries')
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt22
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/extra.cxx17
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/extra.ispc12
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/main.cxx15
-rw-r--r--Tests/ISPC/ChainedStaticLibraries/simple.ispc12
5 files changed, 78 insertions, 0 deletions
diff --git a/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt
new file mode 100644
index 0000000..bf0b57e
--- /dev/null
+++ b/Tests/ISPC/ChainedStaticLibraries/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+cmake_minimum_required(VERSION 3.18)
+project(ISPCChainedStaticLibraries CXX ISPC)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(CMAKE_ISPC_FLAGS "--arch=x86")
+endif()
+
+
+add_library(ispc_objects1 STATIC extra.ispc extra.cxx)
+add_library(ispc_objects2 STATIC simple.ispc)
+
+set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
+set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "avx1-i32x16;avx2-i32x4")
+
+set_target_properties(ispc_objects2 PROPERTIES POSITION_INDEPENDENT_CODE ON)
+set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "avx1-i32x16")
+
+target_link_libraries(ispc_objects2 PRIVATE ispc_objects1)
+
+add_executable(ISPCChainedStaticLibraries main.cxx)
+target_link_libraries(ISPCChainedStaticLibraries PUBLIC ispc_objects2)
diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.cxx b/Tests/ISPC/ChainedStaticLibraries/extra.cxx
new file mode 100644
index 0000000..88ef3a7
--- /dev/null
+++ b/Tests/ISPC/ChainedStaticLibraries/extra.cxx
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+#include "extra.ispc.h"
+
+int extra()
+{
+ float vin[16], vout[16];
+ for (int i = 0; i < 16; ++i)
+ vin[i] = i;
+
+ ispc::extra(vin, vout, 16);
+
+ for (int i = 0; i < 16; ++i)
+ printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]);
+
+ return 0;
+}
diff --git a/Tests/ISPC/ChainedStaticLibraries/extra.ispc b/Tests/ISPC/ChainedStaticLibraries/extra.ispc
new file mode 100644
index 0000000..5a4a442
--- /dev/null
+++ b/Tests/ISPC/ChainedStaticLibraries/extra.ispc
@@ -0,0 +1,12 @@
+
+export void extra(uniform float vin[], uniform float vout[],
+ uniform int count) {
+ foreach (index = 0 ... count) {
+ float v = vin[index];
+ if (v < 3.)
+ v = v * v;
+ else
+ v = sqrt(v);
+ vout[index] = v;
+ }
+}
diff --git a/Tests/ISPC/ChainedStaticLibraries/main.cxx b/Tests/ISPC/ChainedStaticLibraries/main.cxx
new file mode 100644
index 0000000..4f1c9be
--- /dev/null
+++ b/Tests/ISPC/ChainedStaticLibraries/main.cxx
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+#include "simple.ispc.h"
+
+int main()
+{
+ float vin[16], vout[16];
+ for (int i = 0; i < 16; ++i)
+ vin[i] = i;
+
+ ispc::simple(vin, vout, 16);
+
+ for (int i = 0; i < 16; ++i)
+ printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]);
+}
diff --git a/Tests/ISPC/ChainedStaticLibraries/simple.ispc b/Tests/ISPC/ChainedStaticLibraries/simple.ispc
new file mode 100644
index 0000000..70cb588
--- /dev/null
+++ b/Tests/ISPC/ChainedStaticLibraries/simple.ispc
@@ -0,0 +1,12 @@
+
+export void simple(uniform float vin[], uniform float vout[],
+ uniform int count) {
+ foreach (index = 0 ... count) {
+ float v = vin[index];
+ if (v < 3.)
+ v = v * v;
+ else
+ v = sqrt(v);
+ vout[index] = v;
+ }
+}