Merge branch 'release-4-6'
[alexxy/gromacs.git] / src / gromacs / gmxlib / thread_mpi / settings.h
1 /*
2    This source code file is part of thread_mpi.
3    Written by Sander Pronk, Erik Lindahl, and possibly others.
4
5    Copyright (c) 2009, Sander Pronk, Erik Lindahl.
6    All rights reserved.
7
8    Redistribution and use in source and binary forms, with or without
9    modification, are permitted provided that the following conditions are met:
10    1) Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12    2) Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15    3) Neither the name of the copyright holders nor the
16    names of its contributors may be used to endorse or promote products
17    derived from this software without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY
20    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22    DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY
23    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30    If you want to redistribute modifications, please consider that
31    scientific software is very special. Version control is crucial -
32    bugs must be traceable. We will be happy to consider code for
33    inclusion in the official distribution, but derived work should not
34    be called official thread_mpi. Details are found in the README & COPYING
35    files.
36  */
37
38
39 /*#define TMPI_DEBUG*/
40
41
42 /* If this is defined, thread_mpi will print a message when for every MPI
43    call is called or returns. Useful for debugging MPI-related issues
44    in the calling program. */
45 /*#define TMPI_TRACE*/
46
47 /* if this is defined, MPI will warn/hang/crash on practices that don't conform
48    to the MPI standard (such as not calling tMPI_Comm_free on all threads that
49    are part of the comm being freed). */
50 #define TMPI_STRICT
51
52 /* whether to warn if there are mallocs at performance-critical sections
53    (due to preallocations being too small) */
54 #ifdef TMPI_WARNINGS
55 #define TMPI_WARN_MALLOC
56 #else
57 /*#define TMPI_WARN_MALLOC*/
58 #endif
59
60
61 /* the number of envelopes to allocate per thread-to-thread path */
62 #define N_EV_ALLOC 16
63
64 /* the normal maximum number of threads for pre-defined arrays
65    (if the actual number of threads is bigger than this, it'll
66     allocate/deallocate arrays, so no problems will arise). */
67 #define MAX_PREALLOC_THREADS 64
68
69 /* Whether to use lock-free lists using compare-and-swap (cmpxchg on x86)
70    pointer functions. Message passing using blocking Send/Recv, and multicasts
71    are is still blocking, of course. */
72 #define TMPI_LOCK_FREE_LISTS
73
74 /* Whether to disable yielding to the OS scheduler during waits. Disabling
75    this improves performance very slightly if Nthreads<=Ncores on an
76    otherwise idle system because waits have slightly lower latencies, but
77    causes very poor performance if threads are competing for CPU time (for
78    example, when Nthreads>Ncores, or another process is running on the
79    system.
80
81    This option can be set with cmake. */
82 /*#define TMPI_WAIT_FOR_NO_ONE */
83
84
85
86 /* whether to enable double-copying (where the sender copies data to an
87    intermediate buffer for small enough buffers, allowing it to return
88    from a blocking send call early. The receiver is free to copy from the
89    original buffer while the sender is copying, possibly allowing them to
90    work in parallel).
91
92    This option can be set with cmake. */
93 /*#define TMPI_COPY_BUFFER*/
94
95
96 /* The size (in bytes) of the maximum transmission size for which double
97    copying is allowed (i.e. the sender doesn't wait for the receiver to
98    become ready, but posts a copied buffer in its envelope).
99
100    A size of 8192 bytes was chosen after some testing with Gromacs. */
101 #define COPY_BUFFER_SIZE 8192
102 #ifdef TMPI_COPY_BUFFER
103 /* We can separately specify whether we want copy buffers for send/recv or
104    multicast communications: */
105 #define USE_SEND_RECV_COPY_BUFFER
106 #define USE_COLLECTIVE_COPY_BUFFER
107 #endif
108
109
110 /* The number of collective envelopes per comm object. This is the maximum
111    number of simulataneous collective communications that can
112    take place per comm object. If TMPI_NO_COPY_BUFFER is set, simultaneous
113    collective communications don't happen and 2 is the right value.  */
114 #ifdef USE_COLLECTIVE_COPY_BUFFER
115 #define N_COLL_ENV 12
116 #else
117 #define N_COLL_ENV 2
118 #endif
119
120
121 /* Whether to do profiling of the number of MPI communication calls. A
122     report with the total number of calls for each communication function
123     will be generated at MPI_Finalize().
124
125     This option can be set with cmake.*/
126 /*#define TMPI_PROFILE*/
127
128
129 /* whether to turn on thread affinity (required for NUMA optimizations)
130    if the number of threads to spawn is equal to the number of processors. */
131 #define TMPI_THREAD_AFFINITY