| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
WORKDIR=$AUTOPKGTEST_ARTIFACTS |
| 6 |
cd "$WORKDIR" |
| 7 |
|
| 8 |
# Create the cpp file. |
| 9 |
cat <<EOF > test_ispcrt.cpp |
| 10 |
#include <iostream> |
| 11 |
#include "ispcrt.h" |
| 12 |
int main() |
| 13 |
{ |
| 14 |
ISPCRTDevice device = ispcrtGetDevice(ISPCRT_DEVICE_TYPE_AUTO, 0); |
| 15 |
if(!device) |
| 16 |
{ |
| 17 |
std::cerr << "Invalid device" << std::endl; |
| 18 |
return 1; |
| 19 |
} |
| 20 |
ISPCRTDeviceType type = ispcrtGetDeviceType(device); |
| 21 |
if(type == ISPCRT_DEVICE_TYPE_CPU) |
| 22 |
{ |
| 23 |
std::cout << "CPU Device Type" << std::endl; |
| 24 |
} |
| 25 |
else if(type == ISPCRT_DEVICE_TYPE_GPU) |
| 26 |
{ |
| 27 |
std::cout << "GPU Device Type" << std::endl; |
| 28 |
} |
| 29 |
else |
| 30 |
{ |
| 31 |
std::cerr << "Unknown Device Type: " << type << std::endl; |
| 32 |
} |
| 33 |
ispcrtRelease(device); |
| 34 |
return 0; |
| 35 |
} |
| 36 |
EOF |
| 37 |
|
| 38 |
# Create the CMake file. |
| 39 |
cat <<EOF > CMakeLists.txt |
| 40 |
cmake_minimum_required(VERSION 3.29) |
| 41 |
project(test_ispcrt) |
| 42 |
find_package(ispcrt REQUIRED) |
| 43 |
add_executable(test_ispcrt test_ispcrt.cpp) |
| 44 |
target_link_libraries(test_ispcrt ispcrt::ispcrt) |
| 45 |
EOF |
| 46 |
|
| 47 |
echo "building..." |
| 48 |
mkdir build |
| 49 |
cd build |
| 50 |
cmake .. |
| 51 |
make |
| 52 |
|
| 53 |
echo "running..." |
| 54 |
test -x test_ispcrt |
| 55 |
./test_ispcrt |