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 * 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/ */
#include <timing.h> #include <timing.h>
#include <likwid-marker.h>
double copy( double copy(
double * restrict a, double * restrict a,
@@ -37,14 +36,9 @@ double copy(
double S, E; double S, E;
S = getTimeStamp(); S = getTimeStamp();
#pragma omp parallel #pragma omp parallel for schedule(static)
{ for (int i=0; i<N; i++) {
LIKWID_MARKER_START("COPY"); a[i] = b[i];
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = b[i];
}
LIKWID_MARKER_STOP("COPY");
} }
E = getTimeStamp(); E = getTimeStamp();

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
* ======================================================================================= * =======================================================================================
* *
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de * 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
*/ */
#include <timing.h> #include <timing.h>
#include <likwid-marker.h>
double sum( double sum(
double * restrict a, double * restrict a,
@@ -37,14 +36,9 @@ double sum(
double sum = 0.0; double sum = 0.0;
S = getTimeStamp(); S = getTimeStamp();
#pragma omp parallel #pragma omp parallel for reduction(+:sum) schedule(static)
{ for (int i=0; i<N; i++) {
LIKWID_MARKER_START("SUM"); sum += a[i];
#pragma omp for reduction(+:sum) schedule(static)
for (int i=0; i<N; i++) {
sum += a[i];
}
LIKWID_MARKER_STOP("SUM");
} }
E = getTimeStamp(); E = getTimeStamp();

View File

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

View File

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

View File

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

View File

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