Cleaning up tests and printing for demo
This commit is contained in:
2
func.cpp
2
func.cpp
@@ -635,7 +635,7 @@ Function::GenerateIR() {
|
|||||||
const bool
|
const bool
|
||||||
Function::IsPolyFunction() const {
|
Function::IsPolyFunction() const {
|
||||||
for (size_t i = 0; i < args.size(); i++) {
|
for (size_t i = 0; i < args.size(); i++) {
|
||||||
if (args[i]->type->IsPolymorphicType()) {
|
if (args[i] && args[i]->type->IsPolymorphicType()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1061,8 +1061,6 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
|
|
||||||
const Type *ret = eft->GetReturnType();
|
const Type *ret = eft->GetReturnType();
|
||||||
if (Type::EqualForReplacement(ret, pt)) {
|
if (Type::EqualForReplacement(ret, pt)) {
|
||||||
printf("Replaced return type %s\n",
|
|
||||||
ret->GetString().c_str());
|
|
||||||
ret = PolyType::ReplaceType(ret, *te);
|
ret = PolyType::ReplaceType(ret, *te);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1998,6 +1996,7 @@ lPrintPolyFunctionWrappers(FILE *file, const std::vector<std::string> &funcs) {
|
|||||||
for (size_t j=0; j<poly.size(); j++) {
|
for (size_t j=0; j<poly.size(); j++) {
|
||||||
const FunctionType *ftype = CastType<FunctionType>(poly[j]->type);
|
const FunctionType *ftype = CastType<FunctionType>(poly[j]->type);
|
||||||
Assert(ftype);
|
Assert(ftype);
|
||||||
|
if (ftype->isExported || ftype->isExternC) {
|
||||||
std::string decl = ftype->GetCDeclaration(funcs[i]);
|
std::string decl = ftype->GetCDeclaration(funcs[i]);
|
||||||
fprintf(file, " %s {\n", decl.c_str());
|
fprintf(file, " %s {\n", decl.c_str());
|
||||||
|
|
||||||
@@ -2005,6 +2004,7 @@ lPrintPolyFunctionWrappers(FILE *file, const std::vector<std::string> &funcs) {
|
|||||||
fprintf(file, " return %s;\n }\n", call.c_str());
|
fprintf(file, " return %s;\n }\n", call.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(file, "#endif // __cplusplus\n");
|
fprintf(file, "#endif // __cplusplus\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,25 +180,25 @@ int main() {
|
|||||||
minTaskISPC = std::min(minTaskISPC, endTime - startTime);
|
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);
|
verifyResult(N, output, gold);
|
||||||
|
|
||||||
double minDTaskISPC = 1e30;
|
double minDTaskISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
double startTime = CycleTimer::currentSeconds();
|
double startTime = CycleTimer::currentSeconds();
|
||||||
ispc::sqrt_ispc_withtasks(N, initialGuess, values, output);
|
ispc::sqrt_ispc_withtasks(N, dinitialGuess, dvalues, doutput);
|
||||||
double endTime = CycleTimer::currentSeconds();
|
double endTime = CycleTimer::currentSeconds();
|
||||||
minDTaskISPC = std::min(minDTaskISPC, endTime - startTime);
|
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);
|
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 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 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);
|
printf("\t\t\t\t(%.2fx speedup from task ISPC double)\n", minDSerial/minDTaskISPC);
|
||||||
|
|
||||||
delete[] values;
|
delete[] values;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
int main() {
|
int main() {
|
||||||
float A[256];
|
float A[256];
|
||||||
double B[256];
|
double B[256];
|
||||||
double outA[256];
|
float outA[256];
|
||||||
double outB[256];
|
double outB[256];
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ int main() {
|
|||||||
B[i] = 1. / (i+1);
|
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);
|
ispc::square(256, (double*)&B, (double*)&outB);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
floating foo(const uniform int a, floating b) {
|
number pow(number b, int a) {
|
||||||
floating out = b;
|
number out = b;
|
||||||
for (int i = 1; i<a; i++) {
|
for (int i = 1; i<a; i++) {
|
||||||
out *= b;
|
out *= b;
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,8 @@ floating foo(const uniform int a, floating b) {
|
|||||||
return out;
|
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) {
|
foreach (i = 0 ... N) {
|
||||||
out[i] = foo(2, b[i]);
|
out[i] = pow(b[i], 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user