diff --git a/decl.cpp b/decl.cpp index d4d20467..27a6d580 100644 --- a/decl.cpp +++ b/decl.cpp @@ -168,11 +168,13 @@ DeclSpecs::GetBaseType(SourcePos pos) const { retType = lApplyTypeQualifiers(typeQualifiers, retType, pos); if (soaWidth > 0) { +#if 0 /* see stmt.cpp in DeclStmt::EmitCode for work-around of SOAType Declaration */ if (g->target->getISA() == Target::NVPTX) { Error(pos, "\"soa\" data types are currently not supported with \"nvptx\" target."); return NULL; } +#endif const StructType *st = CastType(retType); if (st == NULL) { diff --git a/stmt.cpp b/stmt.cpp index 8b1c6303..2160cbaf 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -264,6 +264,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { return; } + if (sym->storageClass == SC_STATIC) { if (g->target->getISA() == Target::NVPTX && !sym->type->IsConstType()) @@ -328,7 +329,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { // Tell the FunctionEmitContext about the variable ctx->EmitVariableDebugInfo(sym); } - else if (sym->type->IsUniformType() && + else if ((sym->type->IsUniformType() || sym->type->IsSOAType()) && /* NVPTX: * only non-constant uniform data types are stored in shared memory * constant uniform are automatically promoted to varying @@ -357,6 +358,8 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { * instead of compile-time constants */ nel *= at->GetElementCount(); + if (sym->type->IsSOAType()) + nel *= sym->type->GetSOAWidth(); nat = new ArrayType(at->GetElementType(), nel); variable = false; } diff --git a/tests/soa-16.ispc b/tests/soa-16.ispc index f23c39cb..3c6ff6c4 100644 --- a/tests/soa-16.ispc +++ b/tests/soa-16.ispc @@ -15,6 +15,16 @@ static void p(uniform float *uniform ptr) { } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { +#ifdef __NVPTX__ /* soa is converted to shared memory story for now, use smaller amount to check the test */ + soa<4> Point pts[10]; + for (uniform int i = 0; i < 40; ++i) { + pts[i].x = b*i; + pts[i].y[0] = 2*b*i; + pts[i].y[1] = 2*b*i+1; + pts[i].y[2] = 2*b*i+2; + pts[i].z = 3*b*i; + } +#else soa<4> Point pts[30]; for (uniform int i = 0; i < 120; ++i) { pts[i].x = b*i; @@ -23,6 +33,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { pts[i].y[2] = 2*b*i+2; pts[i].z = 3*b*i; } +#endif float a = aFOO[programIndex]; a *= -1; diff --git a/tests/soa-17.ispc b/tests/soa-17.ispc index f25b85bd..897840f3 100644 --- a/tests/soa-17.ispc +++ b/tests/soa-17.ispc @@ -16,6 +16,16 @@ static void p(uniform float *uniform ptr) { } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { +#ifdef __NVPTX__ /* soa is converted to shared memory story for now, use smaller amount to check the test */ + soa<4> Point pts[15]; + for (uniform int i = 0; i < 60; ++i) { + pts[i].x = b*i; + pts[i].y[0] = 2*b*i; + pts[i].y[1] = 2*b*i+1; + pts[i].y[2] = 2*b*i+2; + pts[i].z = 3*b*i; + } +#else soa<4> Point pts[40]; for (uniform int i = 0; i < 160; ++i) { pts[i].x = b*i; @@ -24,11 +34,14 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { pts[i].y[2] = 2*b*i+2; pts[i].z = 3*b*i; } +#endif float a = aFOO[programIndex]; a *= -1; Point vp = { a, { 2*a, 3*a, 4*a }, {5*a} }; +#ifndef __NVPTX__ assert(2+programIndex < 160); +#endif pts[2+programIndex] = vp; RET[programIndex] = pts[programIndex].y[2]; diff --git a/tests/soa-3.ispc b/tests/soa-3.ispc index 2cec07a5..86c7c57c 100644 --- a/tests/soa-3.ispc +++ b/tests/soa-3.ispc @@ -6,6 +6,17 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; +#ifdef __NVPTX__ /* soa is converted to shared memory story for now, use smaller amount to check the test */ + soa<8> Point pts[4]; +//CO uniform Point pts[80]; + foreach (i = 0 ... 40) { + pts[i].x = b*i; + pts[i].y[0] = 2*b*i; + pts[i].y[1] = 2*b*i+1; + pts[i].y[2] = 2*b*i+2; + pts[i].z = 3*b*i; + } +#else soa<8> Point pts[10]; //CO uniform Point pts[80]; foreach (i = 0 ... 80) { @@ -15,6 +26,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { pts[i].y[2] = 2*b*i+2; pts[i].z = 3*b*i; } +#endif assert(programCount < 80); RET[programIndex] = pts[programIndex].y[2];