Commit 5f498305 authored by Jan Eitzinger's avatar Jan Eitzinger
Browse files

Port changes to single file C versions. Formatting.

parent 7bf6790a
......@@ -54,11 +54,10 @@
#define LIKWID_PROFILE(tag,call) \
_Pragma ("omp parallel") \
{LIKWID_MARKER_START(#tag);} \
times[tag][k] = call; \
_Pragma ("omp parallel") \
{LIKWID_MARKER_STOP(#tag);}
{LIKWID_MARKER_START(#tag);} \
times[tag][k] = call; \
_Pragma ("omp parallel") \
{LIKWID_MARKER_STOP(#tag);}
typedef enum benchmark {
INIT = 0,
......@@ -177,7 +176,6 @@ int main (int argc, char** argv)
scalar = 3.0;
for ( int k=0; k < NTIMES; k++) {
LIKWID_PROFILE(INIT,init(b, scalar, N));
tmp = a[10];
LIKWID_PROFILE(SUM,sum(a, N));
......
......@@ -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
......@@ -25,6 +25,7 @@
* =======================================================================================
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
......@@ -53,6 +54,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,
COPY,
......@@ -89,8 +97,8 @@ int main (int argc, char** argv)
double E, S;
double avgtime[NUMBENCH],
maxtime[NUMBENCH],
mintime[NUMBENCH];
maxtime[NUMBENCH],
mintime[NUMBENCH];
double times[NUMBENCH][NTIMES];
......@@ -139,7 +147,7 @@ int main (int argc, char** argv)
}
#endif
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = 2.0;
b[i] = 2.0;
......@@ -150,13 +158,13 @@ int main (int argc, char** argv)
scalar = 3.0;
for ( int k=0; k < NTIMES; k++) {
times[INIT][k] = init(b, scalar, N);
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(INIT,init(b, scalar, 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++) {
......@@ -290,14 +298,9 @@ double init(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("INIT");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = scalar;
}
LIKWID_MARKER_STOP("INIT");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = scalar;
}
E = getTimeStamp();
......@@ -313,14 +316,9 @@ double copy(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("COPY");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = b[i];
}
LIKWID_MARKER_STOP("COPY");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i];
}
E = getTimeStamp();
......@@ -336,14 +334,9 @@ double update(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("UPDATE");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = a[i] * scalar;
}
LIKWID_MARKER_STOP("UPDATE");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] * scalar;
}
E = getTimeStamp();
......@@ -361,14 +354,9 @@ double triad(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("TRIAD");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = b[i] + scalar * c[i];
}
LIKWID_MARKER_STOP("TRIAD");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + scalar * c[i];
}
E = getTimeStamp();
......@@ -385,14 +373,9 @@ double daxpy(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("DAXPY");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = a[i] + scalar * b[i];
}
LIKWID_MARKER_STOP("DAXPY");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] + scalar * b[i];
}
E = getTimeStamp();
......@@ -410,14 +393,9 @@ double striad(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("STRIAD");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = b[i] + d[i] * c[i];
}
LIKWID_MARKER_STOP("STRIAD");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + d[i] * c[i];
}
E = getTimeStamp();
......@@ -434,14 +412,9 @@ double sdaxpy(
double S, E;
S = getTimeStamp();
#pragma omp parallel
{
LIKWID_MARKER_START("SDAXPY");
#pragma omp for
for (int i=0; i<N; i++) {
a[i] = a[i] + b[i] * c[i];
}
LIKWID_MARKER_STOP("SDAXPY");
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] + b[i] * c[i];
}
E = getTimeStamp();
......
......@@ -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
......@@ -126,7 +126,7 @@ int main (int argc, char** argv)
}
#endif
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = 2.0;
b[i] = 2.0;
......@@ -276,7 +276,7 @@ double init(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = scalar;
}
......@@ -294,7 +294,7 @@ double copy(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i];
}
......@@ -312,7 +312,7 @@ double update(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] * scalar;
}
......@@ -332,7 +332,7 @@ double triad(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + scalar * c[i];
}
......@@ -351,7 +351,7 @@ double daxpy(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] + scalar * b[i];
}
......@@ -371,7 +371,7 @@ double striad(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = b[i] + d[i] * c[i];
}
......@@ -390,7 +390,7 @@ double sdaxpy(
double S, E;
S = getTimeStamp();
#pragma omp parallel for
#pragma omp parallel for schedule(static)
for (int i=0; i<N; i++) {
a[i] = a[i] + b[i] * c[i];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment