Commit c805ea80 authored by Hendryk Bockelmann's avatar Hendryk Bockelmann
Browse files

slightly modified tests to get clear output

parent 7beaafe1
......@@ -9,7 +9,7 @@ $ENV{SCT_OUT}="stdout";
# test with 2 MPI tasks
$ENV{SCT_CALLSTATS}=1;
$ENV{SCT_CALLSTATS}=0;
$ENV{SCT_PROC_CHOICE}="SCT_SELECT_ALL";
$ENV{OMP_NUM_THREADS}=2;
#parse(run_prg("@abs_top_builddir@/tests/test_hybrid")) && check_reports();
......
......@@ -19,7 +19,7 @@
#include "sct.h"
#define MY_TIMER_MAX 4
#define MY_TIMER_MAX 3
static const int timer_max = MY_TIMER_MAX;
static int timer[MY_TIMER_MAX];
......@@ -86,27 +86,32 @@ int main ( int argc, char *argv[] ) {
init0();
// sct timer:
char label0[] = "long-label-timer-0";
// setup sct timer
char label0[] = "pure-seq-timer-0";
timer[0] = sct_new_timer(label0);
char label1[] = "even-longer-label-timer-1";
char label1[] = "mixed-called-timer-1";
timer[1] = sct_new_timer(label1);
char label2[] = "timer-2";
char label2[] = "pure-par-timer-2";
timer[2] = sct_new_timer(label2);
char label3[] = "timer-3";
timer[3] = sct_new_timer(label3);
double ts[2], te[2];
int icount = 10*1000*1000;
// total
// setup omp
int max_threads= omp_get_max_threads();
printf("# test_omp: max_threads=%i\n",max_threads);
if (max_threads<1) {
fprintf(stderr,"unexpected zero count of threads\n");
return 1;
}
// start total timer
sct_start(timer[0]);
ts[0] = simple_walltime();
// perform pure serial workload
work(0, icount);
// reference timer resolution:
......@@ -120,34 +125,26 @@ int main ( int argc, char *argv[] ) {
printf("# ref_res = %.12e\n",ref_res);
// sct timer resolution (not using internal method):
double sct_res;
int max_threads= omp_get_max_threads();
printf("# test_omp: max_threads=%i\n",max_threads);
if (max_threads<1) {
fprintf(stderr,"unexpected zero count of threads\n");
return 1;
}
#pragma omp parallel default(shared)
{
int tid = omp_get_thread_num();
check_tid(tid);
double ts, te, t0, t1;
sct_start(timer[1]);
sct_start(timer[2]);
ts = simple_walltime();
t0 = sct_val(timer[1]);
while ( (t1=sct_val(timer[1])) <= t0 ) {};
te = simple_walltime();
t0 = sct_val(timer[2]);
while ( (t1=sct_val(timer[2])) <= t0 ) {};
double res = t1-t0;
sct_stop(timer[1]);
ref_omp_dt(label1, tid, te-ts);
te = simple_walltime();
sct_stop(timer[2]);
printf("# tid=%i, sct_res = %.12e\n",tid, res);
}
// serial measurement:
// serial measurement of mixed timer
sct_start(timer[1]);
ts[1] = simple_walltime();
......@@ -185,10 +182,10 @@ int main ( int argc, char *argv[] ) {
check_tid(tid);
double ts[2], te[2], t0, t1;
sct_start(timer[2]);
sct_start(timer[1]);
ts[0] = simple_walltime();
sct_start(timer[3]);
sct_start(timer[2]);
ts[1] = simple_walltime();
t0 = simple_walltime();
......@@ -198,13 +195,13 @@ int main ( int argc, char *argv[] ) {
t1 = simple_walltime();
double res = t1-t0;
sct_stop(timer[3]);
sct_stop(timer[2]);
te[1] = simple_walltime();
ref_omp_dt(label3, tid, te[1]-ts[1]);
ref_omp_dt(label2, tid, te[1]-ts[1]);
sct_stop(timer[2]);
sct_stop(timer[1]);
te[0] = simple_walltime();
ref_omp_dt(label2, tid, te[0]-ts[0]);
ref_omp_dt(label1, tid, te[0]-ts[0]);
// critical not strictly required here:
#pragma omp critical
......
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