Skip to content
Snippets Groups Projects
Select Git revision
  • f05518465b8bcf58968a0dc986628c0e3ac677dc
  • master default protected
2 results

fold_xpr_demo2.cc

Blame
  • ALL_Staggered.cpp 8.85 KiB
    /*
       Copyright 2020-2020 Stephan Schulz, Forschungszentrum Juelich GmbH, Germany
       Copyright 2018-2020 Rene Halver, Forschungszentrum Juelich GmbH, Germany
       Copyright 2018-2020 Godehard Sutmann, Forschungszentrum Juelich GmbH, Germany
    
       Redistribution and use in source and binary forms, with or without
       modification, are permitted provided that the following conditions are met:
    
       1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
    
       2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    
       3. Neither the name of the copyright holder nor the names of its contributors
       may be used to endorse or promote products derived from this software without
       specific prior written permission.
    
       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
       AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
       LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
       INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
       CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
       ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
       POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <stdlib.h>
    #include <stdio.h>
    //#include <time.h>
    #include <mpi.h>
    
    //#define ALL_VTK_OUTPUT
    
    #ifdef USE_AMALGAMATED
    #include "ALL_Amalgamated.hpp"
    #else
    #include <ALL.hpp>
    #endif
    
    // Run fun in order of ranks
    // Todo(s.schulz): This seems to only work roughly with the result width an 32 ranks, with up to 16 it seems to work correctly.
    //                 Adding sleep(1) also orders everything correctly. So this is probably a flushing problem.
    //                 It also exists for the cout stream with endl.
    #define MPI_RUN_ORDER(comm, rank, max_ranks, fun) {int MPI_RO_IT;\
    	for(MPI_RO_IT=0;MPI_RO_IT<max_ranks;MPI_RO_IT++)\
    	{\
    		if(MPI_RO_IT==rank)\
    		{\
    			fun;\
    			MPI_Barrier(comm);\
    		} else {\
    			MPI_Barrier(comm);\
    		}\
    	}\
    }
    
    // Quick and dirty helper function. Assumes comm, rank and max_ranks
    // CAVEAT: the function call must be wrapped in () if it contains a comma
    #define MPI_RUN_ORDER_DEF(fun) MPI_RUN_ORDER(MPI_COMM_WORLD, MyRank, MaximumRank, fun)
    
    //void millisleep(unsigned long ms)
    //{
    //	struct timespec SleepTime;
    //	SleepTime.tv_sec = ms/1000;