Skip to content

Commit

Permalink
Adapt test system to redefined meaning of "task" functions on GPU.
Browse files Browse the repository at this point in the history
  • Loading branch information
aneshlya authored and dbabokin committed Aug 13, 2021
1 parent 9ab7edc commit 2aa444f
Show file tree
Hide file tree
Showing 1,382 changed files with 4,258 additions and 2,879 deletions.
7 changes: 4 additions & 3 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def run_test(testname, host, target):
match = -1
for line in file:
# look for lines with 'export'...
if line.find("export") == -1:
if line.find("task") == -1 and line.find("export") == -1:
continue
# one of them should have a function with one of the
# declarations in sig2def
Expand Down Expand Up @@ -520,11 +520,12 @@ def run_test(testname, host, target):
exe_name = "./" + exe_name
cc_cmd += " -DTEST_ZEBIN" if options.ispc_output == "ze" else " -DTEST_SPV"

ispc_cmd = ispc_exe_rel + " --woff %s -o %s --arch=%s --target=%s" % \
(filename, obj_name, options.arch, genx_target if target.is_genx() else options.target)
ispc_cmd = ispc_exe_rel + " --woff %s -o %s --arch=%s --target=%s -DTEST_SIG=%d" % \
(filename, obj_name, options.arch, genx_target if target.is_genx() else options.target, match)

if target.is_genx():
ispc_cmd += " --emit-zebin" if options.ispc_output == "ze" else " --emit-spirv"
ispc_cmd += " -DISPC_GPU"
if options.cpu != None:
ispc_cmd += " --cpu="+ options.cpu

Expand Down
50 changes: 25 additions & 25 deletions test_static.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2010-2020, Intel Corporation
Copyright (c) 2010-2021, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -83,18 +83,18 @@
#endif

extern "C" {
extern void CALLINGCONV f_v(float *result);
extern void CALLINGCONV f_f(float *result, float *a);
extern void CALLINGCONV f_fu(float *result, float *a, float b);
extern void CALLINGCONV f_fi(float *result, float *a, int *b);
extern void CALLINGCONV f_du(float *result, double *a, double b);
extern void CALLINGCONV f_duf(float *result, double *a, float b);
extern void CALLINGCONV f_di(float *result, double *a, int *b);
extern void CALLINGCONV print_uf(float a);
extern void CALLINGCONV print_f(float *a);
extern void CALLINGCONV print_fuf(float *a, float b);
extern void CALLINGCONV result(float *val);
extern void CALLINGCONV print_result();
extern void CALLINGCONV f_v_cpu_entry_point(float *result);
extern void CALLINGCONV f_f_cpu_entry_point(float *result, float *a);
extern void CALLINGCONV f_fu_cpu_entry_point(float *result, float *a, float b);
extern void CALLINGCONV f_fi_cpu_entry_point(float *result, float *a, int *b);
extern void CALLINGCONV f_du_cpu_entry_point(float *result, double *a, double b);
extern void CALLINGCONV f_duf_cpu_entry_point(float *result, double *a, float b);
extern void CALLINGCONV f_di_cpu_entry_point(float *result, double *a, int *b);
extern void CALLINGCONV print_uf_cpu_entry_point(float a);
extern void CALLINGCONV print_f_cpu_entry_point(float *a);
extern void CALLINGCONV print_fuf_cpu_entry_point(float *a, float b);
extern void CALLINGCONV result_cpu_entry_point(float *val);
extern void CALLINGCONV print_result_cpu_entry_point();

void ISPCLaunch(void **handlePtr, void *f, void *d, int, int, int);
void ISPCSync(void *handle);
Expand Down Expand Up @@ -174,38 +174,38 @@ int main(int argc, char *argv[]) {
float b = 5.;

#if (TEST_SIG == 0)
f_v(returned_result);
f_v_cpu_entry_point(returned_result);
#elif (TEST_SIG == 1)
f_f(returned_result, vfloat);
f_f_cpu_entry_point(returned_result, vfloat);
#elif (TEST_SIG == 2)
f_fu(returned_result, vfloat, b);
f_fu_cpu_entry_point(returned_result, vfloat, b);
#elif (TEST_SIG == 3)
f_fi(returned_result, vfloat, vint);
f_fi_cpu_entry_point(returned_result, vfloat, vint);
#elif (TEST_SIG == 4)
f_du(returned_result, vdouble, b);
f_du_cpu_entry_point(returned_result, vdouble, b);
#elif (TEST_SIG == 5)
f_duf(returned_result, vdouble, static_cast<float>(b));
f_duf_cpu_entry_point(returned_result, vdouble, static_cast<float>(b));
#elif (TEST_SIG == 6)
f_di(returned_result, vdouble, vint2);
f_di_cpu_entry_point(returned_result, vdouble, vint2);
#elif (TEST_SIG == 7)
*returned_result = sizeof(ispc::f_sz);
w = 1;
#elif (TEST_SIG == 32)
print_uf(static_cast<float>(b));
print_uf_cpu_entry_point(static_cast<float>(b));
#elif (TEST_SIG == 33)
print_f(vfloat);
print_f_cpu_entry_point(vfloat);
#elif (TEST_SIG == 34)
print_fuf(vfloat, static_cast<float>(b));
print_fuf_cpu_entry_point(vfloat, static_cast<float>(b));
#else
#error "Unknown or unset TEST_SIG value"
#endif

float expected_result[ARRAY_SIZE];
memset(expected_result, 0, ARRAY_SIZE * sizeof(float));
#if (TEST_SIG < 32)
result(expected_result);
result_cpu_entry_point(expected_result);
#else
print_result();
print_result_cpu_entry_point();
return 0;
#endif

Expand Down
83 changes: 83 additions & 0 deletions test_static.isph
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Copyright (c) 2021, Intel Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ISPC_GPU
#if (TEST_SIG == 0)
task void f_v(uniform float res[]);
export void f_v_cpu_entry_point(uniform float res[]) { launch[1] f_v(res); }
#elif (TEST_SIG == 1)
task void f_f(uniform float res[], uniform float vfloat[]);
export void f_f_cpu_entry_point(uniform float res[], uniform float vfloat[]) { launch[1] f_f(res, vfloat); }
#elif (TEST_SIG == 2)
task void f_fu(uniform float res[], uniform float vfloat[], uniform float b);
export void f_fu_cpu_entry_point(uniform float res[], uniform float vfloat[], uniform float b) {
launch[1] f_fu(res, vfloat, b);
}
#elif (TEST_SIG == 3)
task void f_fi(uniform float res[], uniform float vfloat[], uniform int vint[]);
export void f_fi_cpu_entry_point(uniform float res[], uniform float vfloat[], uniform int vint[]) {
launch[1] f_fi(res, vfloat, vint);
}
#elif (TEST_SIG == 4)
task void f_du(uniform float res[], uniform double a[], uniform double b);
export void f_du_cpu_entry_point(uniform float res[], uniform double a[], uniform double b) {
launch[1] f_du(res, a, b);
}
#elif (TEST_SIG == 5)
task void f_duf(uniform float res[], uniform double a[], uniform float b);
export void f_duf_cpu_entry_point(uniform float res[], uniform double a[], uniform float b) {
launch[1] f_duf(res, a, b);
}
#elif (TEST_SIG == 6)
task void f_di(uniform float res[], uniform double a[], uniform int b[]);
export void f_di_cpu_entry_point(uniform float res[], uniform double a[], uniform int b[]) {
launch[1] f_di(res, a, b);
}
#elif (TEST_SIG == 32)
task void print_uf(uniform float b);
export void print_uf_cpu_entry_point(uniform float b) { launch[1] print_uf(b); }
#elif (TEST_SIG == 33)
task void print_f(uniform float vfloat[]);
export void print_f_cpu_entry_point(uniform float vfloat[]) { launch[1] print_f(vfloat); }
#elif (TEST_SIG == 34)
task void print_fuf(uniform float vfloat[], uniform float b);
export void print_fuf_cpu_entry_point(uniform float vfloat[], uniform float b) { launch[1] print_fuf(vfloat, b); }
#endif

#if (TEST_SIG < 32)
task void result(uniform float res[]);
export void result_cpu_entry_point(uniform float res[]) { launch[1] result(res); }
#else
task void print_result();
export void print_result_cpu_entry_point() { launch[1] print_result(); }
#endif
#endif
5 changes: 3 additions & 2 deletions tests/1320.ispc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
#include "../test_static.isph"
task void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int v = aFOO[programIndex];
// Shift only if v is greater than 2.
if(v > 2) v = shift(v, -1);
Expand All @@ -7,7 +8,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
RET[programIndex] = v;
}

export void result(uniform float RET[]) {
task void result(uniform float RET[]) {
varying int val = programIndex + 1;
val = val + 2;
if(val > 2) val--;
Expand Down
5 changes: 3 additions & 2 deletions tests/1323-fix.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// This test is written to cover the scenario from issue 1323.
// Structs with uniform vector elements directly or as nested elements fail
// compilation when compiled for multiple targets. To test this use case, this
Expand Down Expand Up @@ -30,7 +31,7 @@ static float check_x1(uniform float3 a[]) {
}


export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {

AABB box;
// Sets value of first vector element value
Expand All @@ -49,6 +50,6 @@ export void f_v(uniform float RET[]) {

}

export void result(uniform float RET[]) {
task void result(uniform float RET[]) {
RET[programIndex] = 16.0;
}
5 changes: 3 additions & 2 deletions tests/1331-enumToInt.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
enum Enum111{
One,
Two
Expand All @@ -12,12 +13,12 @@ int func(int x) {
}


export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
uniform Enum111 enum_ = Two;
int rval = func(enum_);
RET[programIndex] = rval;
}

export void result(uniform float RET[]) {
task void result(uniform float RET[]) {
RET[programIndex] = 3;
}
5 changes: 3 additions & 2 deletions tests/1331-enumToVec.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
enum Enum111{
One,
Two,
Expand All @@ -14,12 +15,12 @@ int func(int<5> x) {
}


export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
uniform Enum111 enum_ = Three;
int rval = func(enum_);
RET[programIndex] = rval;
}

export void result(uniform float RET[]) {
task void result(uniform float RET[]) {
RET[programIndex] = 7;
}
5 changes: 3 additions & 2 deletions tests/1475-f32.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// Testing float implementation of varying * varying
void tests_float(uniform float RET[]) {
varying float p_foo[programCount];
Expand All @@ -19,10 +20,10 @@ void tests_float(uniform float RET[]) {
RET[programIndex] = 1;
}

export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_float(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1475-f64.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// rule: skip on cpu=TGLLP

// Testing double implementation of varying * varying
Expand All @@ -22,10 +23,10 @@ void tests_double(uniform float RET[]) {
}


export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_double(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1475-int16.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// Testing int16 implementation of varying * varying
void tests_int16(uniform float RET[]) {
varying int16 p_foo[programCount];
Expand All @@ -19,10 +20,10 @@ void tests_int16(uniform float RET[]) {
RET[programIndex] = 1;
}

export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_int16(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1475-int32.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// Testing int32 implementation of varying * varying
void tests_int32(uniform float RET[]) {
varying int32 p_foo[programCount];
Expand All @@ -20,10 +21,10 @@ void tests_int32(uniform float RET[]) {
RET[programIndex] = 1;
}

export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_int32(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1475-int64.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// Testing int64 implementation of varying * varying
void tests_int64(uniform float RET[]) {
varying int64 p_foo[programCount];
Expand All @@ -19,10 +20,10 @@ void tests_int64(uniform float RET[]) {
RET[programIndex] = 1;
}

export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_int64(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1475-int8.ispc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../test_static.isph"
// Testing int8 implementation of varying * varying
void tests_int8(uniform float RET[]) {
varying int8 p_foo[programCount];
Expand All @@ -19,10 +20,10 @@ void tests_int8(uniform float RET[]) {
RET[programIndex] = 1;
}

export void f_v(uniform float RET[]) {
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
tests_int8(RET);
}


export void result(uniform float RET[]) { RET[programIndex] = 0; }
task void result(uniform float RET[]) { RET[programIndex] = 0; }
5 changes: 3 additions & 2 deletions tests/1510.ispc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export void f_v(uniform float RET[]) {
#include "../test_static.isph"
task void f_v(uniform float RET[]) {
RET[programIndex] = 0;
uint8 a8 = -6;
if(a8 < 0)
Expand All @@ -23,6 +24,6 @@ export void f_v(uniform float RET[]) {

}

export void result(uniform float RET[]) {
task void result(uniform float RET[]) {
RET[programIndex] = 0;
}
Loading

0 comments on commit 2aa444f

Please sign in to comment.