Skip to content

Commit

Permalink
Update run_tests and examples makefile for scalar target.
Browse files Browse the repository at this point in the history
Fixed a number of tests that didn't handle the programCount == 1
case correctly.
  • Loading branch information
Matt Pharr committed Jan 30, 2012
1 parent f6cd01f commit 0575b1f
Show file tree
Hide file tree
Showing 64 changed files with 168 additions and 107 deletions.
8 changes: 7 additions & 1 deletion examples/common.mk
Expand Up @@ -14,7 +14,7 @@ CPP_OBJS=$(addprefix objs/, $(CPP_SRC:.cpp=.o) $(TASK_OBJ))

default: $(EXAMPLE)

all: $(EXAMPLE) $(EXAMPLE)-sse4 $(EXAMPLE)-generic16
all: $(EXAMPLE) $(EXAMPLE)-sse4 $(EXAMPLE)-generic16 $(EXAMPLE)-scalar

.PHONY: dirs clean

Expand Down Expand Up @@ -57,3 +57,9 @@ objs/$(ISPC_SRC:.ispc=)_generic16.o: objs/$(ISPC_SRC:.ispc=)_generic16.cpp

$(EXAMPLE)-generic16: $(CPP_OBJS) objs/$(ISPC_SRC:.ispc=)_generic16.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)

objs/$(ISPC_SRC:.ispc=)_scalar.o: $(ISPC_SRC)
$(ISPC) $< -o $@ --target=generic-1

$(EXAMPLE)-scalar: $(CPP_OBJS) objs/$(ISPC_SRC:.ispc=)_scalar.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
5 changes: 3 additions & 2 deletions run_tests.py
Expand Up @@ -53,7 +53,8 @@
else:
ispc_exe = "../Release/ispc.exe"

is_generic_target = options.target.find("generic-") != -1
is_generic_target = (options.target.find("generic-") != -1 and
options.target != "generic-1")
if is_generic_target and options.include_file == None:
if options.target == "generic-4":
sys.stderr.write("No generics #include specified; using examples/intrinsics/sse4.h\n")
Expand Down Expand Up @@ -224,7 +225,7 @@ def run_test(filename):
"in test %s\n" % filename)
return (1, 0)
else:
is_generic_target = options.target.find("generic-") != -1
global is_generic_target
if is_generic_target:
obj_name = "%s.cpp" % filename

Expand Down
4 changes: 3 additions & 1 deletion tests/array-gather-multi-unif.ispc
Expand Up @@ -15,7 +15,9 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
}

export void result(uniform float RET[]) {
if (programCount == 4)
if (programCount == 1)
RET[programIndex] = 1;
else if (programCount == 4)
RET[programIndex] = 5.;
else
RET[programIndex] = 10.;
Expand Down
8 changes: 4 additions & 4 deletions tests/array-pointer-duality-1.ispc
Expand Up @@ -3,13 +3,13 @@ export uniform int width() { return programCount; }


export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float a[programCount];
for (unsigned int i = 0; i < programCount; ++i)
a[i] = aFOO[i];
uniform float a[programCount+4];
for (unsigned int i = 0; i < programCount+4; ++i)
a[i] = aFOO[min((int)i, programCount)];

RET[programIndex] = *(a + 2);
}

export void result(uniform float RET[]) {
RET[programIndex] = 3;
RET[programIndex] = (programCount == 1) ? 1 : 3;
}
2 changes: 1 addition & 1 deletion tests/array-scatter-unif-2.ispc
Expand Up @@ -14,4 +14,4 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
}


export void result(uniform float RET[]) { RET[programIndex] = 5; }
export void result(uniform float RET[]) { RET[programIndex] = programCount == 1 ? 0 : 5; }
4 changes: 3 additions & 1 deletion tests/array-scatter-unif.ispc
Expand Up @@ -14,7 +14,9 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {


export void result(uniform float RET[]) {
if (programCount == 4)
if (programCount == 1)
RET[programIndex] = 0;
else if (programCount == 4)
RET[programIndex] = 2;
else
RET[programIndex] = 4;
Expand Down
2 changes: 1 addition & 1 deletion tests/atomics-10.ispc
Expand Up @@ -13,5 +13,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 2;
RET[programIndex] = programCount == 1 ? 1 : 2;
}
2 changes: 1 addition & 1 deletion tests/atomics-13.ispc
Expand Up @@ -12,5 +12,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = (programCount/2) - 1;
RET[programIndex] = programCount == 1 ? 0 : ((programCount/2) - 1);
}
2 changes: 1 addition & 1 deletion tests/atomics-6.ispc
Expand Up @@ -10,5 +10,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 3000;
RET[programIndex] = (programCount == 1) ? 2 : 3000;
}
2 changes: 1 addition & 1 deletion tests/atomics-8.ispc
Expand Up @@ -12,5 +12,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = programCount;
RET[programIndex] = (programCount == 1) ? 0 : programCount;
}
2 changes: 1 addition & 1 deletion tests/atomics-9.ispc
Expand Up @@ -13,5 +13,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 1;
RET[programIndex] = (programCount == 1) ? 0 : 1;
}
2 changes: 1 addition & 1 deletion tests/broadcast-1.ispc
Expand Up @@ -3,7 +3,7 @@ export uniform int width() { return programCount; }

export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int a = aFOO[programIndex];
int br = broadcast(a, (uniform int)b-2);
int br = (programCount == 1) ? 4 : broadcast(a, (uniform int)b-2);
RET[programIndex] = br;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/broadcast-2.ispc
Expand Up @@ -3,7 +3,7 @@ export uniform int width() { return programCount; }

export void f_f(uniform float RET[], uniform float aFOO[]) {
int16 a = aFOO[programIndex];
int16 b = broadcast(a, 2);
int16 b = (programCount == 1) ? 3 : broadcast(a, 2);
RET[programIndex] = b;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/broadcast-3.ispc
Expand Up @@ -3,7 +3,7 @@ export uniform int width() { return programCount; }

export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 a = aFOO[programIndex];
int8 br = broadcast(a, (uniform int)b-2);
int8 br = (programCount == 1) ? 4 : broadcast(a, (uniform int)b-2);
RET[programIndex] = br;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/broadcast.ispc
Expand Up @@ -3,7 +3,7 @@ export uniform int width() { return programCount; }

export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = broadcast(a, 2);
float b = (programCount == 1) ? 3 : broadcast(a, 2);
RET[programIndex] = b;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/extract-1.ispc
Expand Up @@ -3,9 +3,9 @@ export uniform int width() { return programCount; }

export void f_f(uniform float RET[], uniform float aFOO[]) {
double a = programIndex;
RET[programIndex] = extract(a, 3);
RET[programIndex] = extract(a, min(programCount-1, 3));
}

export void result(uniform float RET[]) {
RET[programIndex] = 3;
RET[programIndex] = (programCount == 1) ? 0 : 3;
}
2 changes: 1 addition & 1 deletion tests/packed-load-3.ispc
Expand Up @@ -12,5 +12,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 2;
RET[programIndex] = (programCount == 1) ? 1 : 2;
}
10 changes: 7 additions & 3 deletions tests/packed-load-5.ispc
Expand Up @@ -15,8 +15,12 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
for (uniform int i = 0; i < programCount/2; ++i) {
RET[2*i+1] = 10+i;
RET[2*i] = 10+programCount/2+i;
if (programCount == 1)
RET[0] = 10;
else {
for (uniform int i = 0; i < programCount/2; ++i) {
RET[2*i+1] = 10+i;
RET[2*i] = 10+programCount/2+i;
}
}
}
2 changes: 1 addition & 1 deletion tests/packed-store-3.ispc
Expand Up @@ -13,5 +13,5 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
}

export void result(uniform float RET[]) {
RET[programIndex] = programCount/2;
RET[programIndex] = (programCount == 1) ? 1 : programCount/2;
}
2 changes: 1 addition & 1 deletion tests/popcnt-3.ispc
Expand Up @@ -8,4 +8,4 @@ export void f_f(uniform float RET[4], uniform float aFOO[]) {
RET[programIndex] = popcnt(a < 3);
}

export void result(uniform float RET[]) { RET[programIndex] = 2; }
export void result(uniform float RET[]) { RET[programIndex] = programCount == 1 ? 1 : 2; }
6 changes: 4 additions & 2 deletions tests/ptr-assign-lhs-math-1.ispc
Expand Up @@ -2,8 +2,9 @@
export uniform int width() { return programCount; }

export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float a[programCount];
uniform float a[programCount+1];
a[programIndex] = aFOO[programIndex];
a[programCount] = 1;

uniform float * uniform ptr = a;
*(ptr+1) = 0;
Expand All @@ -12,5 +13,6 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {

export void result(uniform float RET[]) {
RET[programIndex] = 1+programIndex;
RET[1] = 0;
if (programCount > 0)
RET[1] = 0;
}
5 changes: 3 additions & 2 deletions tests/reduce-add-double-1.ispc
Expand Up @@ -5,7 +5,7 @@ export uniform int width() { return programCount; }

export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
double v = aFOO[programIndex];
uniform float m;
uniform float m = 42;
int iv = (int)v;
if (iv & 1)
m = reduce_add((double)iv);
Expand All @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-double-2.ispc
Expand Up @@ -13,7 +13,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 10;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 10;
else if (programCount == 8) x = 36;
else if (programCount == 16) x = 136;
RET[programIndex] = x;
Expand Down
2 changes: 1 addition & 1 deletion tests/reduce-add-double.ispc
Expand Up @@ -11,4 +11,4 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
RET[programIndex] = m;
}

export void result(uniform float RET[]) { RET[programIndex] = -3; }
export void result(uniform float RET[]) { RET[programIndex] = (programCount == 1) ? -1 : -3; }
3 changes: 2 additions & 1 deletion tests/reduce-add-float-1.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-float-2.ispc
Expand Up @@ -13,7 +13,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 10;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 10;
else if (programCount == 8) x = 36;
else if (programCount == 16) x = 136;
RET[programIndex] = x;
Expand Down
2 changes: 1 addition & 1 deletion tests/reduce-add-float.ispc
Expand Up @@ -11,4 +11,4 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
RET[programIndex] = m;
}

export void result(uniform float RET[]) { RET[programIndex] = -3; }
export void result(uniform float RET[]) { RET[programIndex] = (programCount == 1) ? -1 : -3; }
3 changes: 2 additions & 1 deletion tests/reduce-add-int-1.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-int.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 10;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 10;
else if (programCount == 8) x = 36;
else if (programCount == 16) x = 136;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-int64-1.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-int64.ispc
Expand Up @@ -13,7 +13,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 10;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 10;
else if (programCount == 8) x = 36;
else if (programCount == 16) x = 136;
RET[programIndex] = x;
Expand Down
3 changes: 2 additions & 1 deletion tests/reduce-add-uint-1.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
2 changes: 1 addition & 1 deletion tests/reduce-add-uint.ispc
Expand Up @@ -12,4 +12,4 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
RET[programIndex] = m;
}

export void result(uniform float RET[]) { RET[programIndex] = 10 * programCount/4; }
export void result(uniform float RET[]) { RET[programIndex] = (programCount == 1) ? 1 : (10 * programCount/4); }
3 changes: 2 additions & 1 deletion tests/reduce-add-uint64-1.ispc
Expand Up @@ -14,7 +14,8 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {

export void result(uniform float RET[]) {
uniform int x = -1234;
if (programCount == 4) x = 4;
if (programCount == 1) x = 1;
else if (programCount == 4) x = 4;
else if (programCount == 8) x = 16;
else if (programCount == 16) x = 64;
RET[programIndex] = x;
Expand Down
4 changes: 3 additions & 1 deletion tests/reduce-add-uint64.ispc
Expand Up @@ -11,4 +11,6 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
RET[programIndex] = m;
}

export void result(uniform float RET[]) { RET[programIndex] = 10 * programCount/4; }
export void result(uniform float RET[]) {
RET[programIndex] = (programCount == 1) ? 1 : (10 * programCount/4);
}
6 changes: 3 additions & 3 deletions tests/reduce-equal-13.ispc
Expand Up @@ -4,14 +4,14 @@ export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int a = aFOO[programIndex&1];
RET[programIndex] = 1;
uniform bool re;
uniform int val;
uniform bool re = false;
uniform int val = 16;
if (programIndex & 1) {
re = reduce_equal(a, &val);
}
RET[programIndex] = ((int)re << 8) + val;
}

export void result(uniform float RET[]) {
RET[programIndex] = 258;
RET[programIndex] = (programCount == 1) ? 16 : 258;
}
2 changes: 1 addition & 1 deletion tests/reduce-equal-3.ispc
Expand Up @@ -9,5 +9,5 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 0;
RET[programIndex] = (programCount == 1) ? 1 : 0;
}
2 changes: 1 addition & 1 deletion tests/reduce-equal-4.ispc
Expand Up @@ -2,7 +2,7 @@
export uniform int width() { return programCount; }

export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int a = aFOO[programIndex/(programCount/2)];
int a = aFOO[programIndex/max(1, (programCount/2))];
RET[programIndex] = 0;
if (programIndex >= programCount/2 && a < 4)
RET[programIndex] = reduce_equal(a) ? 1 : 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/reduce-equal-9.ispc
Expand Up @@ -11,5 +11,5 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
}

export void result(uniform float RET[]) {
RET[programIndex] = 0;
RET[programIndex] = (programCount == 1) ? 1 : 0;
}

0 comments on commit 0575b1f

Please sign in to comment.