diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/ISPC/DynamicLibrary/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/ISPC/DynamicLibrary/extra.cxx | 8 | ||||
-rw-r--r-- | Tests/ISPC/DynamicLibrary/main.cxx | 22 | ||||
-rw-r--r-- | Tests/ISPC/DynamicLibrary/shim.cxx | 0 | ||||
-rw-r--r-- | Tests/ISPC/DynamicLibrary/simple.cxx | 23 |
5 files changed, 45 insertions, 12 deletions
diff --git a/Tests/ISPC/DynamicLibrary/CMakeLists.txt b/Tests/ISPC/DynamicLibrary/CMakeLists.txt index cbfbb3e..4655090 100644 --- a/Tests/ISPC/DynamicLibrary/CMakeLists.txt +++ b/Tests/ISPC/DynamicLibrary/CMakeLists.txt @@ -9,12 +9,14 @@ endif() add_library(ispc_objects1 STATIC extra.ispc extra.cxx) add_library(ispc_objects2 SHARED simple.ispc) +target_sources(ispc_objects2 PRIVATE simple.cxx) set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4") set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4") -target_link_libraries(ispc_objects2 PRIVATE ispc_objects1) +target_link_libraries(ispc_objects2 PUBLIC ispc_objects1) add_executable(ISPCDynamicLibrary main.cxx) target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2) diff --git a/Tests/ISPC/DynamicLibrary/extra.cxx b/Tests/ISPC/DynamicLibrary/extra.cxx index 88ef3a7..b3623d1 100644 --- a/Tests/ISPC/DynamicLibrary/extra.cxx +++ b/Tests/ISPC/DynamicLibrary/extra.cxx @@ -2,7 +2,13 @@ #include "extra.ispc.h" -int extra() +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int extra() { float vin[16], vout[16]; for (int i = 0; i < 16; ++i) diff --git a/Tests/ISPC/DynamicLibrary/main.cxx b/Tests/ISPC/DynamicLibrary/main.cxx index 4f1c9be..f9072c7 100644 --- a/Tests/ISPC/DynamicLibrary/main.cxx +++ b/Tests/ISPC/DynamicLibrary/main.cxx @@ -1,15 +1,17 @@ -#include <stdio.h> -#include "simple.ispc.h" -int main() -{ - float vin[16], vout[16]; - for (int i = 0; i < 16; ++i) - vin[i] = i; +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif - ispc::simple(vin, vout, 16); +IMPORT int simple(); +int extra(); - for (int i = 0; i < 16; ++i) - printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]); +int main() +{ + extra(); + simple(); + return 0; } diff --git a/Tests/ISPC/DynamicLibrary/shim.cxx b/Tests/ISPC/DynamicLibrary/shim.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/shim.cxx diff --git a/Tests/ISPC/DynamicLibrary/simple.cxx b/Tests/ISPC/DynamicLibrary/simple.cxx new file mode 100644 index 0000000..cb5a779 --- /dev/null +++ b/Tests/ISPC/DynamicLibrary/simple.cxx @@ -0,0 +1,23 @@ +#include <stdio.h> + +#include "simple.ispc.h" + +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT int simple() +{ + 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: extra(%f) = %f\n", i, vin[i], vout[i]); + + return 0; +} |