Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 44 additions & 33 deletions src/libm-benchmarks/bench.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
#define NITER1 100000
#define NITER2 10000
#define NITER (NITER1 * NITER2)
// ARRAY SIZE: N * veclen
#define N 10000
// NUM ITERATIONS
#define ITER 1000
// TOTAL NUMBER OF ITERATIONS
#define NITER (N * ITER)

#define callFuncSLEEF1_1(funcName, name, xmin, xmax, ulp, arg, type) ({ \
printf("%s\n", #funcName); \
uint64_t t = Sleef_currentTimeMicros(); \
for(int j=0;j<NITER2;j++) { \
type *p = (type *)(arg); \
for(int i=0;i<NITER1;i++) funcName(*p++); \
} \
fprintf(fp, name ", %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, ulp, (double)(Sleef_currentTimeMicros() - t) / NITER); \
#define callFuncSLEEF1_1(funcName, name, xmin, xmax, ulp, arg, type_in, type_out) ({ \
printf("%s\n", #funcName); \
uint64_t t0 = Sleef_currentTimeMicros(); \
for(int j=0;j<ITER;j++) { \
type_in *p = (type_in *)(arg); \
for(int i=0;i<N;i++){ \
__attribute__((unused)) type_out out = funcName(*p++); \
} \
} \
uint64_t t1 = Sleef_currentTimeMicros(); \
uint64_t dt = t1-t0; \
fprintf(fp, name ", %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, ulp, (double) dt / NITER); \
})

#define callFuncSLEEF1_2(funcName, name, xmin, xmax, ymin, ymax, ulp, arg1, arg2, type) ({ \
printf("%s\n", #funcName); \
uint64_t t = Sleef_currentTimeMicros(); \
for(int j=0;j<NITER2;j++) { \
type *p1 = (type *)(arg1), *p2 = (type *)(arg2); \
for(int i=0;i<NITER1;i++) funcName(*p1++, *p2++); \
} \
fprintf(fp, name ", %.3g, %.3g, %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, (double)ymin, (double)ymax, ulp, (double)(Sleef_currentTimeMicros() - t) / NITER); \
#define callFuncSLEEF1_2(funcName, name, xmin, xmax, ymin, ymax, ulp, arg1, arg2, type_in, type_out) ({ \
printf("%s\n", #funcName); \
uint64_t t0 = Sleef_currentTimeMicros(); \
for(int j=0;j<ITER;j++) { \
type_in *p1 = (type_in *)(arg1), *p2 = (type_in *)(arg2); \
for(int i=0;i<N;i++){ \
__attribute__((unused)) type_out out = funcName(*p1++, *p2++); \
} \
} \
uint64_t t1 = Sleef_currentTimeMicros(); \
uint64_t dt = t1-t0; \
fprintf(fp, name ", %.3g, %.3g, %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, (double)ymin, (double)ymax, ulp, (double) dt / NITER); \
})

#define callFuncSVML1_1(funcName, name, xmin, xmax, arg, type) ({ \
#define callFuncSVML1_1(funcName, name, xmin, xmax, arg, type_in) ({ \
printf("%s\n", #funcName); \
uint64_t t = Sleef_currentTimeMicros(); \
for(int j=0;j<NITER2;j++) { \
type *p = (type *)(arg); \
for(int i=0;i<NITER1;i++) funcName(*p++); \
for(int j=0;j<ITER;j++) { \
type_in *p = (type_in *)(arg); \
for(int i=0;i<N;i++) funcName(*p++); \
} \
fprintf(fp, name ", %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, (double)SVMLULP, (double)(Sleef_currentTimeMicros() - t) / NITER); \
})

#define callFuncSVML2_1(funcName, name, xmin, xmax, arg, type) ({ \
#define callFuncSVML2_1(funcName, name, xmin, xmax, arg, type_in) ({ \
printf("%s\n", #funcName); \
uint64_t t = Sleef_currentTimeMicros(); \
for(int j=0;j<NITER2;j++) { \
type *p = (type *)(arg), c; \
for(int i=0;i<NITER1;i++) funcName(&c, *p++); \
for(int j=0;j<ITER;j++) { \
type_in *p = (type_in *)(arg), c; \
for(int i=0;i<N;i++) funcName(&c, *p++); \
} \
fprintf(fp, name ", %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, (double)SVMLULP, (double)(Sleef_currentTimeMicros() - t) / NITER); \
})

#define callFuncSVML1_2(funcName, name, xmin, xmax, ymin, ymax, arg1, arg2, type) ({ \
#define callFuncSVML1_2(funcName, name, xmin, xmax, ymin, ymax, arg1, arg2, type_in) ({ \
printf("%s\n", #funcName); \
uint64_t t = Sleef_currentTimeMicros(); \
for(int j=0;j<NITER2;j++) { \
type *p1 = (type *)(arg1), *p2 = (type *)(arg2); \
for(int i=0;i<NITER1;i++) funcName(*p1++, *p2++); \
for(int j=0;j<ITER;j++) { \
type_in *p1 = (type_in *)(arg1), *p2 = (type_in *)(arg2); \
for(int i=0;i<N;i++) funcName(*p1++, *p2++); \
} \
fprintf(fp, name ", %.3g, %.3g, %.3g, %.3g, %gulps, %g\n", \
(double)xmin, (double)xmax, (double)ymin, (double)ymax, (double)SVMLULP, (double)(Sleef_currentTimeMicros() - t) / NITER); \
Expand Down
8 changes: 4 additions & 4 deletions src/libm-benchmarks/benchsleef.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ int cpuSupportsAVX512F() {
#endif

void fillDP(double *buf, double min, double max) {
for(int i=0;i<NITER1*veclen;i++) {
for(int i=0;i<N*veclen;i++) {
double r = ((double)random() + RAND_MAX * (double)random()) / (RAND_MAX * (double)RAND_MAX);
buf[i] = r * (max - min) + min;
}
}

void fillSP(float *buf, double min, double max) {
for(int i=0;i<NITER1*veclen;i++) {
for(int i=0;i<N*veclen;i++) {
double r = ((double)random() + RAND_MAX * (double)random()) / (RAND_MAX * (double)RAND_MAX);
buf[i] = r * (max - min) + min;
}
Expand Down Expand Up @@ -86,8 +86,8 @@ int main(int argc, char **argv) {
#error Unsupported architecture
#endif

posix_memalign((void **)&abufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double));
posix_memalign((void **)&bbufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double));
posix_memalign((void **)&abufdp, veclen*sizeof(double), N*veclen*sizeof(double));
posix_memalign((void **)&bbufdp, veclen*sizeof(double), N*veclen*sizeof(double));

abufsp = (float *)abufdp;
bbufsp = (float *)bbufdp;
Expand Down
Loading