summaryrefslogtreecommitdiffstats
path: root/Tests/ISPC/ObjectLibrary
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-06-30 14:13:53 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-08-28 15:21:31 (GMT)
commite783bf8aa6f90ddb1458c7b1a78c5d0225c1496a (patch)
treeb59fe2e01365d0ec14d79f38be8bede5afde6a62 /Tests/ISPC/ObjectLibrary
parent34cc6acc81758e29f8c88607c21ab11d8807f87c (diff)
downloadCMake-e783bf8aa6f90ddb1458c7b1a78c5d0225c1496a.zip
CMake-e783bf8aa6f90ddb1458c7b1a78c5d0225c1496a.tar.gz
CMake-e783bf8aa6f90ddb1458c7b1a78c5d0225c1496a.tar.bz2
ISPC: Support ISPC header generation byproducts and parallel builds
Diffstat (limited to 'Tests/ISPC/ObjectLibrary')
-rw-r--r--Tests/ISPC/ObjectLibrary/CMakeLists.txt11
-rw-r--r--Tests/ISPC/ObjectLibrary/extra.cxx17
-rw-r--r--Tests/ISPC/ObjectLibrary/extra.ispc12
-rw-r--r--Tests/ISPC/ObjectLibrary/main.cxx2
4 files changed, 37 insertions, 5 deletions
diff --git a/Tests/ISPC/ObjectLibrary/CMakeLists.txt b/Tests/ISPC/ObjectLibrary/CMakeLists.txt
index edfbdd8..333ad66 100644
--- a/Tests/ISPC/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ISPC/ObjectLibrary/CMakeLists.txt
@@ -3,12 +3,15 @@ cmake_minimum_required(VERSION 3.18)
project(ISPCObjectLibrary CXX ISPC)
set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON)
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(CMAKE_ISPC_FLAGS "--arch=x86")
+endif()
-add_library(ispc_objects OBJECT simple.ispc)
+add_library(ispc_objects OBJECT simple.ispc extra.ispc)
+
+target_compile_options(ispc_objects PRIVATE "$<$<COMPILE_LANGUAGE:ISPC>:--target=sse2-i32x4>")
-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(ISPCObjectLibrary main.cxx)
+add_executable(ISPCObjectLibrary main.cxx extra.cxx)
target_link_libraries(ISPCObjectLibrary PRIVATE ispc_objects)
diff --git a/Tests/ISPC/ObjectLibrary/extra.cxx b/Tests/ISPC/ObjectLibrary/extra.cxx
new file mode 100644
index 0000000..88ef3a7
--- /dev/null
+++ b/Tests/ISPC/ObjectLibrary/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/ObjectLibrary/extra.ispc b/Tests/ISPC/ObjectLibrary/extra.ispc
new file mode 100644
index 0000000..5a4a442
--- /dev/null
+++ b/Tests/ISPC/ObjectLibrary/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/ObjectLibrary/main.cxx b/Tests/ISPC/ObjectLibrary/main.cxx
index a6b91a6..4f1c9be 100644
--- a/Tests/ISPC/ObjectLibrary/main.cxx
+++ b/Tests/ISPC/ObjectLibrary/main.cxx
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include "simple_ispc.h"
+#include "simple.ispc.h"
int main()
{