File: test-libispcrt

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (55 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

set -e

WORKDIR=$AUTOPKGTEST_ARTIFACTS
cd "$WORKDIR"

# Create the cpp file.
cat <<EOF > test_ispcrt.cpp
#include <iostream>
#include "ispcrt.h"
int main()
{
    ISPCRTDevice device = ispcrtGetDevice(ISPCRT_DEVICE_TYPE_AUTO, 0);
    if(!device)
    {
        std::cerr << "Invalid device" << std::endl;
        return 1;
    }
    ISPCRTDeviceType type = ispcrtGetDeviceType(device);
    if(type == ISPCRT_DEVICE_TYPE_CPU)
    {
        std::cout << "CPU Device Type" << std::endl;
    }
    else if(type == ISPCRT_DEVICE_TYPE_GPU)
    {
        std::cout << "GPU Device Type" << std::endl;
    }
    else
    {
        std::cerr << "Unknown Device Type: " << type << std::endl;
    }
    ispcrtRelease(device);
    return 0;
}
EOF

# Create the CMake file.
cat <<EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.29)
project(test_ispcrt)
find_package(ispcrt REQUIRED)
add_executable(test_ispcrt test_ispcrt.cpp)
target_link_libraries(test_ispcrt ispcrt::ispcrt)
EOF

echo "building..."
mkdir build
cd build
cmake ..
make

echo "running..."
test -x test_ispcrt
./test_ispcrt