diff --git a/module.cpp b/module.cpp index 1031667a..fde31456 100644 --- a/module.cpp +++ b/module.cpp @@ -675,6 +675,21 @@ lCheckExportedParameterTypes(const Type *type, const std::string &name, } } +static void +lCheckTaskParameterTypes(const Type *type, const std::string &name, + SourcePos pos) { + if (g->target->getISA() != Target::NVPTX) + return; + if (lRecursiveCheckValidParamType(type, false) == false) { + if (CastType(type)) + Error(pos, "Vector-typed parameter \"%s\" is illegal in a task " + "function with \"nvptx\" target.", name.c_str()); + else + Error(pos, "Varying parameter \"%s\" is illegal in a task function with \"nvptx\" target.", + name.c_str()); + } +} + /** Given a function type, loop through the function parameters and see if any are StructTypes. If so, issue an error; this is currently broken @@ -881,6 +896,9 @@ Module::AddFunctionDeclaration(const std::string &name, if (functionType->isExported) { lCheckExportedParameterTypes(argType, argName, argPos); } + if (functionType->isTask) { + lCheckTaskParameterTypes(argType, argName, argPos); + } // ISPC assumes that no pointers alias. (It should be possible to // specify when this is not the case, but this should be the diff --git a/tests/launch-8.ispc b/tests/launch-8.ispc index dcc2b6b9..9855a963 100644 --- a/tests/launch-8.ispc +++ b/tests/launch-8.ispc @@ -7,7 +7,8 @@ export uniform int width() { return programCount; } #define N2 50 static uniform float array[N2][N1][N0]; -task void x(const float f) { +task void x(const uniform float farray[]) { + const float f = farray[programIndex]; uniform int j; assert(taskCount == (uniform int32)N0*N1*N2); @@ -30,7 +31,7 @@ task void x(const float f) { array[i2][i1][i0] = i; } export void f_f(uniform float RET[], uniform float fFOO[]) { - float f = fFOO[programIndex]; + uniform float * uniform f = fFOO; launch[N2][N1][N0] x(f); sync; RET[programIndex] = array[N2-1][N1-1][N0-1]; diff --git a/tests/launch-9.ispc b/tests/launch-9.ispc index be9e4881..dbbb9f80 100644 --- a/tests/launch-9.ispc +++ b/tests/launch-9.ispc @@ -7,7 +7,8 @@ export uniform int width() { return programCount; } #define N2 50 static uniform float array[N2][N1][N0]; -task void x(const float f) { +task void x(const uniform float farray[]) { + const float f = farray[programIndex]; uniform int j; assert(taskCount == (int32)N0*N1*N2); @@ -30,8 +31,8 @@ task void x(const float f) { array[i2][i1][i0] = i; } export void f_f(uniform float RET[], uniform float fFOO[]) { - float f = fFOO[programIndex]; - launch[N0,N1,N2] x(f); + uniform float * uniform f = fFOO; + launch[N2][N1][N0] x(f); sync; RET[programIndex] = array[N2-1][N1-1][N0-1]; }