summaryrefslogtreecommitdiffstats
path: root/Tests/ISPC/StaticLibrary
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-07-16 19:18:55 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-08-28 15:21:31 (GMT)
commit34cc6acc81758e29f8c88607c21ab11d8807f87c (patch)
tree38effcd493f057f6148f4d8f58262dfb27afaa24 /Tests/ISPC/StaticLibrary
parent419d70d49000e10c36d9615574ff03513f2edf0d (diff)
downloadCMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.zip
CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.gz
CMake-34cc6acc81758e29f8c88607c21ab11d8807f87c.tar.bz2
Add ISPC compiler support to CMake
Diffstat (limited to 'Tests/ISPC/StaticLibrary')
-rw-r--r--Tests/ISPC/StaticLibrary/CMakeLists.txt12
-rw-r--r--Tests/ISPC/StaticLibrary/main.cxx15
-rw-r--r--Tests/ISPC/StaticLibrary/simple.ispc12
3 files changed, 39 insertions, 0 deletions
diff --git a/Tests/ISPC/StaticLibrary/CMakeLists.txt b/Tests/ISPC/StaticLibrary/CMakeLists.txt
new file mode 100644
index 0000000..b057544
--- /dev/null
+++ b/Tests/ISPC/StaticLibrary/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 3.18)
+project(ISPCStaticLibrary CXX ISPC)
+
+add_library(ispc_objects STATIC simple.ispc)
+
+target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4;--arch=x86-64>")
+target_include_directories(ispc_objects INTERFACE "${CMAKE_CURRENT_BINARY_DIR}")
+set_target_properties(ispc_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
+add_executable(ISPCStaticLibrary main.cxx)
+target_link_libraries(ISPCStaticLibrary PRIVATE ispc_objects)
diff --git a/Tests/ISPC/StaticLibrary/main.cxx b/Tests/ISPC/StaticLibrary/main.cxx
new file mode 100644
index 0000000..a6b91a6
--- /dev/null
+++ b/Tests/ISPC/StaticLibrary/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/StaticLibrary/simple.ispc b/Tests/ISPC/StaticLibrary/simple.ispc
new file mode 100644
index 0000000..70cb588
--- /dev/null
+++ b/Tests/ISPC/StaticLibrary/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;
+ }
+}