Cleaning up tests and printing for demo

This commit is contained in:
2017-05-11 21:16:08 -04:00
parent 34d26554bf
commit 2921430e45
5 changed files with 17 additions and 17 deletions

View File

@@ -635,7 +635,7 @@ Function::GenerateIR() {
const bool
Function::IsPolyFunction() const {
for (size_t i = 0; i < args.size(); i++) {
if (args[i]->type->IsPolymorphicType()) {
if (args[i] && args[i]->type->IsPolymorphicType()) {
return true;
}
}

View File

@@ -1061,8 +1061,6 @@ Module::AddFunctionDeclaration(const std::string &name,
const Type *ret = eft->GetReturnType();
if (Type::EqualForReplacement(ret, pt)) {
printf("Replaced return type %s\n",
ret->GetString().c_str());
ret = PolyType::ReplaceType(ret, *te);
}
@@ -1998,11 +1996,13 @@ lPrintPolyFunctionWrappers(FILE *file, const std::vector<std::string> &funcs) {
for (size_t j=0; j<poly.size(); j++) {
const FunctionType *ftype = CastType<FunctionType>(poly[j]->type);
Assert(ftype);
std::string decl = ftype->GetCDeclaration(funcs[i]);
fprintf(file, " %s {\n", decl.c_str());
if (ftype->isExported || ftype->isExternC) {
std::string decl = ftype->GetCDeclaration(funcs[i]);
fprintf(file, " %s {\n", decl.c_str());
std::string call = ftype->GetCCall(poly[j]->name);
fprintf(file, " return %s;\n }\n", call.c_str());
std::string call = ftype->GetCCall(poly[j]->name);
fprintf(file, " return %s;\n }\n", call.c_str());
}
}
}

View File

@@ -180,25 +180,25 @@ int main() {
minTaskISPC = std::min(minTaskISPC, endTime - startTime);
}
printf("[sqrt float task ispc]:\t[%.3f] ms\n", minTaskISPC * 1000);
printf("[sqrt float task ispc]:\t\t[%.3f] ms\n", minTaskISPC * 1000);
verifyResult(N, output, gold);
double minDTaskISPC = 1e30;
for (int i = 0; i < 3; ++i) {
double startTime = CycleTimer::currentSeconds();
ispc::sqrt_ispc_withtasks(N, initialGuess, values, output);
ispc::sqrt_ispc_withtasks(N, dinitialGuess, dvalues, doutput);
double endTime = CycleTimer::currentSeconds();
minDTaskISPC = std::min(minDTaskISPC, endTime - startTime);
}
printf("[sqrt double task ispc]:\t[%.3f] ms\n", minTaskISPC * 1000);
printf("[sqrt double task ispc]:\t[%.3f] ms\n", minDTaskISPC * 1000);
verifyResult(N, output, gold);
printf("\t\t\t\t(%.2fx speedup from ISPC float)\n", minSerial/minISPC);
printf("\t\t\t\t(%.2fx speedup from task ISPC float)\n", minSerial/minTaskISPC);
printf("\t\t\t\t(%.2fx speedup from ISPC double)\n", minDSerial/minDISPC);
printf("\t\t\t\t(%.2fx speedup from task ISPC float)\n", minSerial/minTaskISPC);
printf("\t\t\t\t(%.2fx speedup from task ISPC double)\n", minDSerial/minDTaskISPC);
delete[] values;

View File

@@ -6,7 +6,7 @@
int main() {
float A[256];
double B[256];
double outA[256];
float outA[256];
double outB[256];
@@ -15,7 +15,7 @@ int main() {
B[i] = 1. / (i+1);
}
ispc::square(256, (float*)&A, (double*)&outA);
ispc::square(256, (float*)&A, (float*)&outA);
ispc::square(256, (double*)&B, (double*)&outB);

View File

@@ -1,5 +1,5 @@
floating foo(const uniform int a, floating b) {
floating out = b;
number pow(number b, int a) {
number out = b;
for (int i = 1; i<a; i++) {
out *= b;
}
@@ -7,8 +7,8 @@ floating foo(const uniform int a, floating b) {
return out;
}
export void square(uniform int N, uniform floating b[], uniform double out[]) {
export void square(uniform int N, uniform number b[], uniform number out[]) {
foreach (i = 0 ... N) {
out[i] = foo(2, b[i]);
out[i] = pow(b[i], 2);
}
}