Pull out likwid intrumentation from benchmark functions.

This commit is contained in:
Jan Eitzinger
2020-12-08 15:20:56 +01:00
parent 072bda515d
commit 279d3fca5c
11 changed files with 49 additions and 83 deletions

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double copy(
double * restrict a,
@@ -37,15 +36,10 @@ double copy(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("COPY");
#pragma omp for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i];
}
LIKWID_MARKER_STOP("COPY");
}
E = getTimeStamp();
return E-S;

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double init(
double * restrict a,
@@ -37,15 +36,10 @@ double init(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("INIT");
#pragma omp for schedule(static)
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = scalar;
}
LIKWID_MARKER_STOP("INIT");
}
E = getTimeStamp();
return E-S;

View File

@@ -52,6 +52,13 @@
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#endif
#define LIKWID_PROFILE(tag,call) \
_Pragma ("omp parallel") \
{LIKWID_MARKER_START("tag");} \
times[tag][k] = call; \
_Pragma ("omp parallel") \
{LIKWID_MARKER_STOP("tag");}
typedef enum benchmark {
INIT = 0,
SUM,
@@ -169,16 +176,16 @@ int main (int argc, char** argv)
scalar = 3.0;
for ( int k=0; k < NTIMES; k++) {
times[INIT][k] = init(b, scalar, N);
LIKWID_PROFILE(INIT,init(b, scalar, N));
tmp = a[10];
times[SUM][k] = sum(a, N);
LIKWID_PROFILE(SUM,sum(a, N));
a[10] = tmp;
times[COPY][k] = copy(c, a, N);
times[UPDATE][k] = update(a, scalar, N);
times[TRIAD][k] = triad(a, b, c, scalar, N);
times[DAXPY][k] = daxpy(a, b, scalar, N);
times[STRIAD][k] = striad(a, b, c, d, N);
times[SDAXPY][k] = sdaxpy(a, b, c, N);
LIKWID_PROFILE(COPY,copy(c, a, N));
LIKWID_PROFILE(UPDATE,update(a, scalar, N));
LIKWID_PROFILE(TRIAD,triad(a, b, c, scalar, N));
LIKWID_PROFILE(DAXPY,daxpy(a, b, scalar, N));
LIKWID_PROFILE(STRIAD,striad(a, b, c, d, N));
LIKWID_PROFILE(SDAXPY,sdaxpy(a, b, c, N));
}
for (int j=0; j<NUMBENCH; j++) {

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double sdaxpy(
double * restrict a,
@@ -38,15 +37,10 @@ double sdaxpy(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("SDAXPY");
#pragma omp for schedule(static)
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] + b[i] * c[i];
}
LIKWID_MARKER_STOP("SDAXPY");
}
E = getTimeStamp();
return E-S;

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double striad(
double * restrict a,
@@ -39,15 +38,10 @@ double striad(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("STRIAD");
#pragma omp for schedule(static)
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + d[i] * c[i];
}
LIKWID_MARKER_STOP("STRIAD");
}
E = getTimeStamp();
return E-S;

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double sum(
double * restrict a,
@@ -37,15 +36,10 @@ double sum(
double sum = 0.0;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("SUM");
#pragma omp for reduction(+:sum) schedule(static)
#pragma omp parallel for reduction(+:sum) schedule(static)
for (int i=0; i<N; i++) {
sum += a[i];
}
LIKWID_MARKER_STOP("SUM");
}
E = getTimeStamp();
/* make the compiler think this makes actually sense */

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double triad(
double * restrict a,
@@ -39,15 +38,10 @@ double triad(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("TRIAD");
#pragma omp for schedule(static)
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + scalar * c[i];
}
LIKWID_MARKER_STOP("TRIAD");
}
E = getTimeStamp();
return E-S;

View File

@@ -2,7 +2,7 @@
* =======================================================================================
*
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
* Copyright (c) 2019 RRZE, University Erlangen-Nuremberg
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/
#include <timing.h>
#include <likwid-marker.h>
double update(
double * restrict a,
@@ -37,15 +36,10 @@ double update(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("UPDATE");
#pragma omp for schedule(static)
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] * scalar;
}
LIKWID_MARKER_STOP("UPDATE");
}
E = getTimeStamp();
return E-S;

View File

@@ -38,8 +38,8 @@
#include <likwid-marker.h>
#define SIZE 40000000ull
#define NTIMES 10
#define SIZE 120000000ull
#define NTIMES 5
#define ARRAY_ALIGNMENT 64
#define HLINE "----------------------------------------------------------------------------\n"

View File

@@ -25,6 +25,7 @@
* =======================================================================================
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -36,8 +37,8 @@
#include <omp.h>
#endif
#define SIZE 40000000ull
#define NTIMES 10
#define SIZE 120000000ull
#define NTIMES 5
#define ARRAY_ALIGNMENT 64
#define HLINE "----------------------------------------------------------------------------\n"