added uniform memory test.
This commit is contained in:
@@ -817,6 +817,13 @@ Module::AddFunctionDeclaration(const std::string &name,
|
||||
Type::Equal(functionType->GetReturnType(), AtomicType::Void) == false)
|
||||
Error(pos, "Task-qualified functions must have void return type.");
|
||||
|
||||
if (g->target->getISA() == Target::NVPTX &&
|
||||
Type::Equal(functionType->GetReturnType(), AtomicType::Void) == false &&
|
||||
functionType->isExported)
|
||||
{
|
||||
Error(pos, "Export-qualified functions must have void return type with \"nvptx\" target.");
|
||||
}
|
||||
|
||||
if (functionType->isExported || functionType->isExternC)
|
||||
lCheckForStructParameters(functionType, pos);
|
||||
|
||||
@@ -2356,8 +2363,6 @@ Module::CompileAndOutput(const char *srcFile,
|
||||
if (name[i] == '.')
|
||||
name[i] = '_';
|
||||
I->setName(name);
|
||||
fprintf(stderr, " %s \n", name.c_str());
|
||||
|
||||
}
|
||||
}
|
||||
if (outputType == CXX) {
|
||||
|
||||
@@ -53,8 +53,9 @@
|
||||
|
||||
#include "ispc_malloc.h"
|
||||
|
||||
#define N 32
|
||||
extern "C" {
|
||||
int width() { return 32; }
|
||||
int width() { return N; }
|
||||
extern void f_v(float *result);
|
||||
extern void f_f(float *result, float *a);
|
||||
extern void f_fu(float *result, float *a, float b);
|
||||
@@ -67,15 +68,15 @@ extern "C" {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int w = width();
|
||||
assert(w <= 64);
|
||||
assert(w <= N);
|
||||
|
||||
float *returned_result = new float[64];
|
||||
float *vfloat = new float[64];
|
||||
double *vdouble = new double[64];
|
||||
int *vint = new int[64];
|
||||
int *vint2 = new int[64];
|
||||
float *returned_result = new float[N];
|
||||
float *vfloat = new float[N];
|
||||
double *vdouble = new double[N];
|
||||
int *vint = new int[N];
|
||||
int *vint2 = new int[N];
|
||||
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
for (int i = 0; i < N; ++i) {
|
||||
returned_result[i] = -1e20;
|
||||
vfloat[i] = i+1;
|
||||
vdouble[i] = i+1;
|
||||
@@ -99,17 +100,18 @@ int main(int argc, char *argv[]) {
|
||||
f_duf(returned_result, vdouble, 5.f);
|
||||
#elif (TEST_SIG == 6)
|
||||
f_di(returned_result, vdouble, vint2);
|
||||
#else
|
||||
Nelse
|
||||
#error "Unknown or unset TEST_SIG value"
|
||||
#endif
|
||||
|
||||
float *expected_result = new float[64];
|
||||
memset(expected_result, 0, 64*sizeof(float));
|
||||
float *expected_result = new float[N];
|
||||
memset(expected_result, 0, N*sizeof(float));
|
||||
result(expected_result);
|
||||
|
||||
int errors = 0;
|
||||
for (int i = 0; i < w; ++i) {
|
||||
if (returned_result[i] != expected_result[i]) {
|
||||
if (returned_result[i] != expected_result[i])
|
||||
{
|
||||
#ifdef EXPECT_FAILURE
|
||||
// bingo, failed
|
||||
return 1;
|
||||
|
||||
41
tests/uniform-1.ispc
Normal file
41
tests/uniform-1.ispc
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
|
||||
task void f_f_task(uniform float RET[], uniform float aFOO[]) {
|
||||
uniform float val[programCount];
|
||||
for (uniform int i = 0; i < programCount; ++i)
|
||||
val[i] = 0;
|
||||
|
||||
foreach (i = 0 ... programCount)
|
||||
val[i] += aFOO[programCount*taskIndex + i] - 1;
|
||||
|
||||
uniform float sum = 0;
|
||||
for (uniform int i = 0; i < programCount; ++i)
|
||||
sum += val[i];
|
||||
|
||||
if (programIndex < 32/4)
|
||||
RET[programCount/4*taskIndex + programIndex] = sum;
|
||||
}
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[])
|
||||
{
|
||||
launch[4] f_f_task(RET, aFOO);
|
||||
}
|
||||
task void result_task(uniform float RET[])
|
||||
{
|
||||
uniform float ret = -1;
|
||||
switch (taskIndex)
|
||||
{
|
||||
case 0: ret = 496; break;
|
||||
case 1: ret = 1520; break;
|
||||
case 2: ret = 2544; break;
|
||||
case 3: ret = 3568; break;
|
||||
}
|
||||
if (programIndex < 32/4)
|
||||
RET[programCount/4*taskIndex + programIndex] = ret;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
launch[4] result_task(RET);
|
||||
}
|
||||
Reference in New Issue
Block a user