From d5daef8bce7b75c1140dfd310922c78f895b924f Mon Sep 17 00:00:00 2001 From: Victor Lopez Date: Wed, 10 Oct 2018 11:05:19 +0200 Subject: [PATCH] Replace macros by functions in slicer tests --- tests/test/05_plugins/slicer/slicer_for.h | 127 ----------- tests/test/05_plugins/slicer/slicer_for.hpp | 206 ++++++++++++++++++ .../05_plugins/slicer/slicer_for_dynamic.cpp | 105 ++------- .../slicer/slicer_for_dynamic_empty.cpp | 106 ++------- .../05_plugins/slicer/slicer_for_guided.cpp | 105 ++------- .../slicer/slicer_for_guided_empty.cpp | 106 ++------- .../slicer/slicer_for_interleaved.cpp | 105 ++------- .../slicer/slicer_for_interleaved_empty.cpp | 106 ++------- .../05_plugins/slicer/slicer_for_static.cpp | 101 ++------- .../slicer/slicer_for_static_empty.cpp | 102 ++------- .../05_plugins/worksharing/worksharing.hpp | 3 +- 11 files changed, 355 insertions(+), 817 deletions(-) delete mode 100644 tests/test/05_plugins/slicer/slicer_for.h create mode 100644 tests/test/05_plugins/slicer/slicer_for.hpp diff --git a/tests/test/05_plugins/slicer/slicer_for.h b/tests/test/05_plugins/slicer/slicer_for.h deleted file mode 100644 index 39f834f38..000000000 --- a/tests/test/05_plugins/slicer/slicer_for.h +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************************/ -/* Copyright 2009-2018 Barcelona Supercomputing Center */ -/* */ -/* This file is part of the NANOS++ library. */ -/* */ -/* NANOS++ is free software: you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public License as published by */ -/* the Free Software Foundation, either version 3 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* NANOS++ is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with NANOS++. If not, see . */ -/*************************************************************************************/ - -#ifndef _SLICER_FOR_H -#define _SLICER_FOR_H - -#ifdef INVERT_LOOP_BOUNDARIES -#define EXECUTE(get_slicer,slicer_data,upper2,lower2,k_offset,step2,chunk2)\ - for ( i = 0; i < NUM_ITERS; i++ ) {\ - _loop_data.offset = -k_offset; \ - sys.loadPlugin( "slicer-" + std::string(get_slicer) ); \ - Slicer *slicer = sys.getSlicer ( get_slicer ); \ - WD * wd = new WorkDescriptor( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t),( void * ) &_loop_data, 0, NULL, NULL );\ - wd->setSlicer(slicer);\ - _loop_data.loop_info.lower = lower2 + k_offset; \ - _loop_data.loop_info.upper = upper2 + k_offset; \ - _loop_data.loop_info.step = step2; \ - _loop_data.loop_info.chunk = chunk2; \ - WD *wg = getMyThreadSafe()->getCurrentWD();\ - wg->addWork( *wd );\ - if ( sys.getPMInterface().getInternalDataSize() > 0 ) { \ - char *idata = NEW char[sys.getPMInterface().getInternalDataSize()]; \ - sys.getPMInterface().initInternalData( idata ); \ - wd->setInternalData( idata ); \ - } \ - sys.setupWD( *wd, (nanos::WD *) wg );\ - sys.submit( *wd );\ - wg->waitCompletion();\ - if (step2 > 0 ) for ( int j = lower2+k_offset; j <= upper2+k_offset; j+= step2 ) A[j+_loop_data.offset]--; \ - else if ( step2 < 0 ) for ( int j = lower2+k_offset; j >= upper2+k_offset; j+= step2 ) A[j+_loop_data.offset]--; \ - } -#else -#define EXECUTE(get_slicer,slicer_data,lower2,upper2,k_offset,step2,chunk2)\ - for ( i = 0; i < NUM_ITERS; i++ ) {\ - _loop_data.offset = -k_offset; \ - sys.loadPlugin( "slicer-" + std::string(get_slicer) ); \ - Slicer *slicer = sys.getSlicer ( get_slicer ); \ - WD * wd = new WorkDescriptor( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t),( void * ) &_loop_data, 0, NULL, NULL );\ - wd->setSlicer(slicer);\ - _loop_data.loop_info.lower = lower2 + k_offset; \ - _loop_data.loop_info.upper = upper2 + k_offset; \ - _loop_data.loop_info.step = step2; \ - _loop_data.loop_info.chunk = chunk2; \ - WD *wg = getMyThreadSafe()->getCurrentWD();\ - wg->addWork( *wd );\ - if ( sys.getPMInterface().getInternalDataSize() > 0 ) { \ - char *idata = NEW char[sys.getPMInterface().getInternalDataSize()]; \ - sys.getPMInterface().initInternalData( idata ); \ - wd->setInternalData( idata ); \ - } \ - sys.setupWD( *wd, (nanos::WD *) wg );\ - sys.submit( *wd );\ - wg->waitCompletion();\ - if (step2 > 0 ) for ( int j = lower2+k_offset; j <= upper2+k_offset; j+= step2 ) A[j+_loop_data.offset]--; \ - else if ( step2 < 0 ) for ( int j = lower2+k_offset; j >= upper2+k_offset; j+= step2 ) A[j+_loop_data.offset]--; \ - } -#endif - -#define FINALIZE(type,lower,upper,offset,step,chunk)\ - print_vector();\ - if ( I[0] == STEP_ERROR ) { step_error = true; I[0] = 0;}\ - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ )\ - if ( I[i] != 0 ) {\ - if ( (i < VECTOR_MARGIN) || (i > (VECTOR_SIZE + VECTOR_MARGIN))) out_of_range = true;\ - if ( (I[i] != NUM_ITERS) && (I[i] != -NUM_ITERS)) race_condition = true;\ - I[i] = 0; check = false; p_check = false;\ - }\ - fprintf(stderr, "%s, lower (%s), upper (%s), offset (%s), step(%+03d), chunk(%02d): %s %s %s %s\n",\ - type, lower, upper, offset, step, chunk,\ - p_check?" successful":"unsuccessful",\ - out_of_range?" - Out of Range":"",\ - race_condition?" - Race Condition":"",\ - step_error?" - Step Error":""\ - );\ - p_check = true; out_of_range = false; race_condition = false; step_error = false; - - -#define TEST(test_type,test_slicer_data,test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, 0, VECTOR_SIZE, 0, +test_step, test_chunk)\ - FINALIZE (test_type,"0","+","+0000",+test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, VECTOR_SIZE-1, -1, 0, -test_step, test_chunk)\ - FINALIZE (test_type,"+","0","+0000",-test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, 0, VECTOR_SIZE, -VECTOR_SIZE, +test_step, test_chunk)\ - FINALIZE (test_type,"-","0","-VS ",+test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, VECTOR_SIZE-1, -1, -VECTOR_SIZE, -test_step, test_chunk)\ - FINALIZE (test_type,"0","-","-VS ",-test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, 0, VECTOR_SIZE, VECTOR_SIZE/2, +test_step, test_chunk)\ - FINALIZE (test_type,"+","+","+VS/2",+test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, VECTOR_SIZE-1, -1, VECTOR_SIZE/2, -test_step, test_chunk)\ - FINALIZE (test_type,"+","+","+VS/2",-test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, 0, VECTOR_SIZE, -(VECTOR_SIZE/2), +test_step, test_chunk)\ - FINALIZE (test_type,"-","+","-VS/2",+test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, VECTOR_SIZE-1, -1, -(VECTOR_SIZE/2), -test_step, test_chunk)\ - FINALIZE (test_type,"+","-","-VS/2",-test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, 0, VECTOR_SIZE, -(2*VECTOR_SIZE), +test_step, test_chunk)\ - FINALIZE (test_type,"-","-","-VS ",+test_step,test_chunk)\ - EXECUTE(test_type, test_slicer_data, VECTOR_SIZE-1, -1, -(2*VECTOR_SIZE), -test_step, test_chunk)\ - FINALIZE (test_type,"-","-","-VS ",-test_step,test_chunk) - -#define TEST_SLICER(test_slicer_type, test_slicer_slicer_data) \ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_A, NUM_A)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_B, NUM_A)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_C, NUM_A)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_A, NUM_B)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_B, NUM_B)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_C, NUM_B)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_A, NUM_C)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_B, NUM_C)\ - TEST(test_slicer_type, test_slicer_slicer_data, NUM_C, NUM_C) - -#endif diff --git a/tests/test/05_plugins/slicer/slicer_for.hpp b/tests/test/05_plugins/slicer/slicer_for.hpp new file mode 100644 index 000000000..b9cc39596 --- /dev/null +++ b/tests/test/05_plugins/slicer/slicer_for.hpp @@ -0,0 +1,206 @@ +/*************************************************************************************/ +/* Copyright 2009-2018 Barcelona Supercomputing Center */ +/* */ +/* This file is part of the NANOS++ library. */ +/* */ +/* NANOS++ is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU Lesser General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* NANOS++ is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU Lesser General Public License */ +/* along with NANOS++. If not, see . */ +/*************************************************************************************/ + +#ifndef _SLICER_FOR_H +#define _SLICER_FOR_H + +#if !defined(NUM_ITERS) || \ + !defined(VECTOR_SIZE) || \ + !defined(VECTOR_MARGIN) +#error "Define NUM_ITERS, VECTOR_SIZE and VECTOR_MARGIN before including worksharing.hpp" +#endif +#ifndef NUM_ITERS +#error Define NUM_ITERS before including __FILE__ +#endif + +#include "nanos.h" +#include "system_decl.hpp" +#include "slicer_decl.hpp" +#include "smpprocessor.hpp" +#include "plugin.hpp" +#include +#include + +using namespace nanos; +using namespace nanos::ext; + +enum { STEP_ERR = -17 }; + +typedef struct { + nanos_loop_info_t loop_info; + int offset; +} main__loop_1_data_t; + +void main__loop_1(void *args); +void execute(std::string slicer_name, int lower, int upper, int offset, int step, int chunk); +int check(const char *desc, const char *lower, const char *upper, + const char *offset, int step, int chunk); +int slicer_test(std::string slicer, const char *desc, int step, int chunk); +void print_vector(); + +static int I[VECTOR_SIZE+2*VECTOR_MARGIN] = {0}; +static int *A = &I[VECTOR_MARGIN]; + + +void main__loop_1 ( void *args ) +{ + main__loop_1_data_t *hargs = (main__loop_1_data_t*) args; + int lower = hargs->loop_info.lower; + int upper = hargs->loop_info.upper; + int step = hargs->loop_info.step; + int offset = hargs->offset; + +#ifdef VERBOSE + fprintf(stderr,"[%d..%d:%d/%d]", lower, upper, step, offset); +#endif + + if ( step > 0 ) { + for ( int i = lower; i <= upper; i += step) { + A[i+offset]++; + } + } + else if ( step < 0 ) { + for ( int i = lower; i >= upper; i += step) { + A[i+offset]++; + } + } + else { + A[-VECTOR_MARGIN] = STEP_ERR; + } +} + +void execute(std::string slicer_name, int lower, int upper, int offset, int step, int chunk) +{ +#ifdef INVERT_LOOP_BOUNDARIES + int _lower = lower; + lower = upper; + upper = _lower; +#endif + + for (int i = 0; i < NUM_ITERS; i++) { + /* Load plugin */ + sys.loadPlugin( "slicer-" + slicer_name ); + Slicer *slicer = sys.getSlicer ( slicer_name ); + + /* set up Work Descriptor */ + main__loop_1_data_t _loop_data; + _loop_data.offset = -offset; + WD * wd = new WorkDescriptor( new SMPDD( main__loop_1 ), sizeof( _loop_data ), + __alignof__(nanos_loop_info_t),( void * ) &_loop_data, 0, NULL, NULL ); + wd->setSlicer( slicer ); + _loop_data.loop_info.lower = lower + offset; + _loop_data.loop_info.upper = upper + offset; + _loop_data.loop_info.step = step; + _loop_data.loop_info.chunk = chunk; + + /* Submit and wait completion */ + WD *wg = getMyThreadSafe()->getCurrentWD(); + wg->addWork( *wd ); + if ( sys.getPMInterface().getInternalDataSize() > 0 ) { + char *idata = NEW char[sys.getPMInterface().getInternalDataSize()]; + sys.getPMInterface().initInternalData( idata ); + wd->setInternalData( idata ); + } + sys.setupWD( *wd, (nanos::WD *) wg ); + sys.submit( *wd ); + wg->waitCompletion(); + + /* Undo increment done by the worksharing */ + if (step > 0) + for (int j = lower+offset; j <= upper+offset; j+= step) + A[j-offset]--; + else if (step < 0) + for (int j = lower+offset; j >= upper+offset; j+= step) + A[j-offset]--; + } +} + +int check(const char *desc, const char *lower, const char *upper, + const char *offset, int step, int chunk) +{ + int error = 0; + bool out_of_range = false, race_condition = false, step_error = false; + + if (I[0] == STEP_ERR) { + step_error = true; + I[0] = 0; + } + + for (int i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++) { + if (I[i] != 0) { + if ((i < VECTOR_MARGIN) || (i > (VECTOR_SIZE + VECTOR_MARGIN))) out_of_range = true; + if ((I[i] != NUM_ITERS) && (I[i] != -NUM_ITERS)) race_condition = true; + I[i] = 0; + error++; + } + } + + fprintf(stderr, + "%s, lower (%s), upper (%s), offset (%s), step(%+03d), chunk(%02d): %s%s%s%s\n", + desc, lower, upper, offset, step, chunk, + error == 0 ? " successful" : " unsuccessful", + out_of_range ? " - Out of Range" : "", + race_condition ? " - Race Condition" : "", + step_error ? " - Step Error" : "" + ); + + return error; +} + +int slicer_test(std::string slicer, const char *desc, int step, int chunk) +{ + int error = 0; + + execute(slicer, 0, VECTOR_SIZE, 0, +step, chunk); + error += check(desc, "0", "+", "+0000", +step, chunk); + execute(slicer, VECTOR_SIZE-1, -1, 0, -step, chunk); + error += check(desc, "+", "0", "+0000", -step, chunk); + execute(slicer, 0, VECTOR_SIZE, -VECTOR_SIZE, +step, chunk); + error += check(desc, "-", "0", "-VS ", +step, chunk); + execute(slicer, VECTOR_SIZE-1, -1, -VECTOR_SIZE, -step, chunk); + error += check(desc, "0", "-", "-VS ", -step, chunk); + execute(slicer, 0, VECTOR_SIZE, VECTOR_SIZE/2, +step, chunk); + error += check(desc, "+", "+", "+VS/2", +step, chunk); + execute(slicer, VECTOR_SIZE-1, -1, VECTOR_SIZE/2, -step, chunk); + error += check(desc, "+", "+", "+VS/2", -step, chunk); + execute(slicer, 0, VECTOR_SIZE, -(VECTOR_SIZE/2), +step, chunk); + error += check(desc, "-", "+", "-VS/2", +step, chunk); + execute(slicer, VECTOR_SIZE-1, -1, -(VECTOR_SIZE/2), -step, chunk); + error += check(desc, "+", "-", "-VS/2", -step, chunk); + execute(slicer, 0, VECTOR_SIZE, -(2*VECTOR_SIZE), +step, chunk); + error += check(desc, "-", "-", "-VS ", +step, chunk); + execute(slicer, VECTOR_SIZE-1, -1, -(2*VECTOR_SIZE), -step, chunk); + error += check(desc, "-", "-", "-VS ", -step, chunk); + + return error; +} + +void print_vector() +{ +#ifdef EXTRA_VERBOSE + for (int i = -VECTOR_MARGIN; i < 0; i++) fprintf(stderr,"%d:",A[i]); + fprintf(stderr,"["); + for (int i = 0; i < VECTOR_SIZE; i++) fprintf(stderr,"%d:",A[i]); + fprintf(stderr,"]"); + for (int i = VECTOR_SIZE; i < VECTOR_SIZE+VECTOR_MARGIN; i++ ) fprintf(stderr,"%d:",A[i]); + fprintf(stderr,"\n"); +#endif +} + +#endif /* SLICER_FOR_HPP */ diff --git a/tests/test/05_plugins/slicer/slicer_for_dynamic.cpp b/tests/test/05_plugins/slicer/slicer_for_dynamic.cpp index 8c9e28961..480761f39 100644 --- a/tests/test/05_plugins/slicer/slicer_for_dynamic.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_dynamic.cpp @@ -23,24 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 1 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -50,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 1 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +//#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; + int error = 0; -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; - - // omp for: dynamic policy (chunk != 0) #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: dynamic_for begins.\n"); #endif - TEST_SLICER("dynamic_for", SlicerDataFor) + error += slicer_test("dynamic_for", "sched_dynamic (A,A)", NUM_A, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (B,A)", NUM_B, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (C,A)", NUM_C, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (A,B)", NUM_A, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (B,B)", NUM_B, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (C,B)", NUM_C, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (A,C)", NUM_A, NUM_C); + error += slicer_test("dynamic_for", "sched_dynamic (B,C)", NUM_B, NUM_C); + error += slicer_test("dynamic_for", "sched_dynamic (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: dynamic_for ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_dynamic_empty.cpp b/tests/test/05_plugins/slicer/slicer_for_dynamic_empty.cpp index 8a2785c13..0411b85ec 100644 --- a/tests/test/05_plugins/slicer/slicer_for_dynamic_empty.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_dynamic_empty.cpp @@ -23,25 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#define INVERT_LOOP_BOUNDARIES -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -51,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; + int error = 0; -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; - - // omp for: dynamic policy (chunk != 0) #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: dynamic_for begins.\n"); #endif - TEST_SLICER("dynamic_for", SlicerDataFor) + error += slicer_test("dynamic_for", "sched_dynamic (A,A)", NUM_A, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (B,A)", NUM_B, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (C,A)", NUM_C, NUM_A); + error += slicer_test("dynamic_for", "sched_dynamic (A,B)", NUM_A, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (B,B)", NUM_B, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (C,B)", NUM_C, NUM_B); + error += slicer_test("dynamic_for", "sched_dynamic (A,C)", NUM_A, NUM_C); + error += slicer_test("dynamic_for", "sched_dynamic (B,C)", NUM_B, NUM_C); + error += slicer_test("dynamic_for", "sched_dynamic (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: dynamic_for ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_guided.cpp b/tests/test/05_plugins/slicer/slicer_for_guided.cpp index ec3cda871..36579f237 100644 --- a/tests/test/05_plugins/slicer/slicer_for_guided.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_guided.cpp @@ -23,24 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -50,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +//#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: guided_for begins.\n"); #endif - TEST_SLICER("guided_for", SlicerDataFor) + error += slicer_test("guided_for", "sched_guided (A,A)", NUM_A, NUM_A); + error += slicer_test("guided_for", "sched_guided (B,A)", NUM_B, NUM_A); + error += slicer_test("guided_for", "sched_guided (C,A)", NUM_C, NUM_A); + error += slicer_test("guided_for", "sched_guided (A,B)", NUM_A, NUM_B); + error += slicer_test("guided_for", "sched_guided (B,B)", NUM_B, NUM_B); + error += slicer_test("guided_for", "sched_guided (C,B)", NUM_C, NUM_B); + error += slicer_test("guided_for", "sched_guided (A,C)", NUM_A, NUM_C); + error += slicer_test("guided_for", "sched_guided (B,C)", NUM_B, NUM_C); + error += slicer_test("guided_for", "sched_guided (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: guided_for ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_guided_empty.cpp b/tests/test/05_plugins/slicer/slicer_for_guided_empty.cpp index 42955dbf5..2577dbb52 100644 --- a/tests/test/05_plugins/slicer/slicer_for_guided_empty.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_guided_empty.cpp @@ -23,25 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#define INVERT_LOOP_BOUNDARIES -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -51,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: guided_for begins.\n"); #endif - TEST_SLICER("guided_for", SlicerDataFor) + error += slicer_test("guided_for", "sched_guided (A,A)", NUM_A, NUM_A); + error += slicer_test("guided_for", "sched_guided (B,A)", NUM_B, NUM_A); + error += slicer_test("guided_for", "sched_guided (C,A)", NUM_C, NUM_A); + error += slicer_test("guided_for", "sched_guided (A,B)", NUM_A, NUM_B); + error += slicer_test("guided_for", "sched_guided (B,B)", NUM_B, NUM_B); + error += slicer_test("guided_for", "sched_guided (C,B)", NUM_C, NUM_B); + error += slicer_test("guided_for", "sched_guided (A,C)", NUM_A, NUM_C); + error += slicer_test("guided_for", "sched_guided (B,C)", NUM_B, NUM_C); + error += slicer_test("guided_for", "sched_guided (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: guided_for ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_interleaved.cpp b/tests/test/05_plugins/slicer/slicer_for_interleaved.cpp index da72d4038..646b0a092 100644 --- a/tests/test/05_plugins/slicer/slicer_for_interleaved.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_interleaved.cpp @@ -23,24 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -50,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +//#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (interleaved) begins.\n"); #endif - TEST_SLICER("static_for", SlicerDataFor) + error += slicer_test("static_for", "sched_static (A,A)", NUM_A, NUM_A); + error += slicer_test("static_for", "sched_static (B,A)", NUM_B, NUM_A); + error += slicer_test("static_for", "sched_static (C,A)", NUM_C, NUM_A); + error += slicer_test("static_for", "sched_static (A,B)", NUM_A, NUM_B); + error += slicer_test("static_for", "sched_static (B,B)", NUM_B, NUM_B); + error += slicer_test("static_for", "sched_static (C,B)", NUM_C, NUM_B); + error += slicer_test("static_for", "sched_static (A,C)", NUM_A, NUM_C); + error += slicer_test("static_for", "sched_static (B,C)", NUM_B, NUM_C); + error += slicer_test("static_for", "sched_static (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (interleaved) ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_interleaved_empty.cpp b/tests/test/05_plugins/slicer/slicer_for_interleaved_empty.cpp index 40f1311f3..915a9f891 100644 --- a/tests/test/05_plugins/slicer/slicer_for_interleaved_empty.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_interleaved_empty.cpp @@ -23,25 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#define INVERT_LOOP_BOUNDARIES -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -51,86 +32,39 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (interleaved) begins.\n"); #endif - TEST_SLICER("static_for", SlicerDataFor) + error += slicer_test("static_for", "sched_static (A,A)", NUM_A, NUM_A); + error += slicer_test("static_for", "sched_static (B,A)", NUM_B, NUM_A); + error += slicer_test("static_for", "sched_static (C,A)", NUM_C, NUM_A); + error += slicer_test("static_for", "sched_static (A,B)", NUM_A, NUM_B); + error += slicer_test("static_for", "sched_static (B,B)", NUM_B, NUM_B); + error += slicer_test("static_for", "sched_static (C,B)", NUM_C, NUM_B); + error += slicer_test("static_for", "sched_static (A,C)", NUM_A, NUM_C); + error += slicer_test("static_for", "sched_static (B,C)", NUM_B, NUM_C); + error += slicer_test("static_for", "sched_static (C,C)", NUM_C, NUM_C); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (interleaved) ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_static.cpp b/tests/test/05_plugins/slicer/slicer_for_static.cpp index c1ab26277..385b9c694 100644 --- a/tests/test/05_plugins/slicer/slicer_for_static.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_static.cpp @@ -23,24 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -50,88 +32,33 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +//#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (static) begins.\n"); #endif - TEST("static_for", SlicerDataFor, NUM_A, 0) - TEST("static_for", SlicerDataFor, NUM_B, 0) - TEST("static_for", SlicerDataFor, NUM_C, 0) + error += slicer_test("static_for", "sched_static (A,0)", NUM_A, 0); + error += slicer_test("static_for", "sched_static (B,0)", NUM_B, 0); + error += slicer_test("static_for", "sched_static (C,0)", NUM_C, 0); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (static) ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/slicer/slicer_for_static_empty.cpp b/tests/test/05_plugins/slicer/slicer_for_static_empty.cpp index e195b7b47..bd485ac9d 100644 --- a/tests/test/05_plugins/slicer/slicer_for_static_empty.cpp +++ b/tests/test/05_plugins/slicer/slicer_for_static_empty.cpp @@ -23,25 +23,6 @@ test_generator=gens/core-generator */ -#include "config.hpp" -#include -#include -#include "smpprocessor.hpp" -#include "system.hpp" -#include "slicer.hpp" -#include "plugin.hpp" -#define INVERT_LOOP_BOUNDARIES -#include "slicer_for.h" - -using namespace std; - -using namespace nanos; -using namespace nanos::ext; - -#define NUM_ITERS 20 -#define VECTOR_SIZE 1000 -#define VECTOR_MARGIN 20 - // The program will create all possible permutation using NUM_{A,B,C} // for step and chunk. For a complete testing purpose they have to be: // - single step/chunk: 1 ('one') @@ -51,88 +32,33 @@ using namespace nanos::ext; #define NUM_B 5 #define NUM_C 13 -#define STEP_ERROR 17 +// Mandatory definitions before including "slicer_for.hpp" +#define NUM_ITERS 20 +#define VECTOR_SIZE 1000 +#define VECTOR_MARGIN 20 -// Output information level: +// Optional definitions before including "slicer_for.hpp" //#define VERBOSE //#define EXTRA_VERBOSE +#define INVERT_LOOP_BOUNDARIES -int *A; - -void print_vector(); - -typedef struct { - nanos_loop_info_t loop_info; - int offset; -} main__loop_1_data_t; - -void main__loop_1 ( void *args ); - -void main__loop_1 ( void *args ) -{ - int i; - main__loop_1_data_t *hargs = (main__loop_1_data_t * ) args; -#ifdef VERBOSE - fprintf(stderr,"[%d..%d:%d/%d]", - hargs->loop_info.lower, hargs->loop_info.upper, hargs->loop_info.step, hargs->offset); -#endif - if ( hargs->loop_info.step > 0 ) - { - for ( i = hargs->loop_info.lower; i <= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else if ( hargs->loop_info.step < 0 ) - { - for ( i = hargs->loop_info.lower; i >= hargs->loop_info.upper; i += hargs->loop_info.step) { - A[i+hargs->offset]++; - } - } - else {A[-VECTOR_MARGIN] = STEP_ERROR; } - -} - -void print_vector () -{ -#ifdef EXTRA_VERBOSE - for ( int j = -5; j < 0; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"["); - for ( int j = 0; j <= VECTOR_SIZE; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"]"); - for ( int j = VECTOR_SIZE+1; j < VECTOR_SIZE+6; j++ ) fprintf(stderr,"%d:",A[j]); - fprintf(stderr,"\n"); -#endif -} +#include "slicer_for.hpp" +#include int main ( int argc, char **argv ) { - int i; - bool check = true; - bool p_check = true, out_of_range = false, race_condition = false, step_error= false; - int I[VECTOR_SIZE+2*VECTOR_MARGIN]; - main__loop_1_data_t _loop_data; - - A = &I[VECTOR_MARGIN]; - -#ifdef VERBOSE - fprintf(stderr,"SLICER_FOR: Initializing vector.\n"); -#endif - - // initialize vector - for ( i = 0; i < VECTOR_SIZE+2*VECTOR_MARGIN; i++ ) I[i] = 0; + int error = 0; #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (static) begins.\n"); #endif - TEST("static_for", SlicerDataFor, NUM_A, 0) - TEST("static_for", SlicerDataFor, NUM_B, 0) - TEST("static_for", SlicerDataFor, NUM_C, 0) + error += slicer_test("static_for", "sched_static (A,0)", NUM_A, 0); + error += slicer_test("static_for", "sched_static (B,0)", NUM_B, 0); + error += slicer_test("static_for", "sched_static (C,0)", NUM_C, 0); #ifdef VERBOSE fprintf(stderr,"SLICER_FOR: static_for (static) ends.\n"); #endif - // final result - //fprintf(stderr, "%s : %s\n", argv[0], check ? " successful" : "unsuccessful"); - if (check) { return 0; } else { return -1; } + std::cout << argv[0] << (!error ? ": successful" : ": unsuccessful") << std::endl; + return error ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/test/05_plugins/worksharing/worksharing.hpp b/tests/test/05_plugins/worksharing/worksharing.hpp index 502da598f..a1ffe458a 100644 --- a/tests/test/05_plugins/worksharing/worksharing.hpp +++ b/tests/test/05_plugins/worksharing/worksharing.hpp @@ -50,7 +50,6 @@ void print_vector(); static int I[VECTOR_SIZE+2*VECTOR_MARGIN] = {0}; static int *A = &I[VECTOR_MARGIN]; -static int error = 0; void execute(nanos_omp_sched_t sched, int lower, int upper, int offset, int step, int chunk) { @@ -134,7 +133,7 @@ int ws_test(nanos_omp_sched_t sched, const char *desc, int step, int chunk) int error = 0; execute(sched, 0, VECTOR_SIZE, 0, +step, chunk); - error += check(desc, "0", "+", "+0000",+ step, chunk); + error += check(desc, "0", "+", "+0000", +step, chunk); execute(sched, VECTOR_SIZE-1, -1, 0, -step, chunk); error += check(desc, "+", "0", "+0000", -step, chunk); execute(sched, 0, VECTOR_SIZE, -VECTOR_SIZE, +step, chunk); -- GitLab