47
tests_errors/func-call-through-variable.ispc
Normal file
47
tests_errors/func-call-through-variable.ispc
Normal file
@@ -0,0 +1,47 @@
|
||||
// Must provide function name or function pointer for function call expression
|
||||
|
||||
export void saxpy_ispc(uniform int N,
|
||||
uniform float scale,
|
||||
uniform float X[],
|
||||
uniform float Y[],
|
||||
uniform float result[])
|
||||
{
|
||||
foreach (i = 0 ... N) {
|
||||
result[i] = scale * X[i] + Y[i];
|
||||
}
|
||||
}
|
||||
|
||||
task void saxpy_ispc_task(uniform int N,
|
||||
uniform int span,
|
||||
uniform float scale,
|
||||
uniform float X[],
|
||||
uniform float Y[],
|
||||
uniform float result[])
|
||||
{
|
||||
uniform int indexStart;
|
||||
uniform int indexEnd;
|
||||
indexStart = (taskIndex * span);
|
||||
indexEnd = min(N, indexStart + (span)/8);
|
||||
foreach (i = indexStart ... indexEnd) {
|
||||
result[i] = scale * X[i] + Y[i];
|
||||
}
|
||||
uniform int k =0;
|
||||
for (k=0; k<8;k++) {
|
||||
indexStart = (((7-taskIndex-k)%8) * span) + k(span/8);
|
||||
indexEnd = min(N, indexStart + (span)/8);
|
||||
foreach (i = indexStart ... indexEnd) {
|
||||
result[i] = scale * X[i] + Y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
export void saxpy_ispc_withtasks(uniform int N,
|
||||
uniform float scale,
|
||||
uniform float X[],
|
||||
uniform float Y[],
|
||||
uniform float result[])
|
||||
{
|
||||
|
||||
uniform int span = N / 8; // 8 tasks
|
||||
|
||||
launch[N/span] < saxpy_ispc_task(N, span, scale, X, Y, result) >;
|
||||
}
|
||||
5
tests_errors/new-delete-1.ispc
Normal file
5
tests_errors/new-delete-1.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// Illegal to delete non-pointer type
|
||||
|
||||
void func(int a) {
|
||||
delete a;
|
||||
}
|
||||
5
tests_errors/new-delete-2.ispc
Normal file
5
tests_errors/new-delete-2.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// Syntax error
|
||||
|
||||
int * func(int a) {
|
||||
return const new int[a];
|
||||
}
|
||||
5
tests_errors/new-delete-3.ispc
Normal file
5
tests_errors/new-delete-3.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// Syntax error
|
||||
|
||||
int * func(int a) {
|
||||
return new int[a](10);
|
||||
}
|
||||
7
tests_errors/new-delete-4.ispc
Normal file
7
tests_errors/new-delete-4.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Type conversion only possible from atomic types
|
||||
|
||||
struct P { int x; };
|
||||
|
||||
int * func(P p) {
|
||||
return new int[p];
|
||||
}
|
||||
5
tests_errors/new-delete-5.ispc
Normal file
5
tests_errors/new-delete-5.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// Illegal to provide "varying" allocation count with "uniform new" expression
|
||||
|
||||
int * func(int x) {
|
||||
return uniform new int[x];
|
||||
}
|
||||
5
tests_errors/new-delete-6.ispc
Normal file
5
tests_errors/new-delete-6.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// Can't convert from varying type "int32 *" to uniform type "int32 * uniform" for return
|
||||
|
||||
int * uniform func(int x) {
|
||||
return new int[x];
|
||||
}
|
||||
12
tests_errors/new-delete-7.ispc
Normal file
12
tests_errors/new-delete-7.ispc
Normal file
@@ -0,0 +1,12 @@
|
||||
// Can't convert from varying type "float" to uniform type "uniform float" for initializer
|
||||
|
||||
struct Point {
|
||||
uniform float x, y, z;
|
||||
};
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
float a = aFOO[programIndex];
|
||||
uniform Point * uniform buf = uniform new uniform Point(a, b, 1234.);
|
||||
RET[programIndex] = buf->y;
|
||||
delete buf;
|
||||
}
|
||||
Reference in New Issue
Block a user