Merge branch 'master' of git@git.gromacs.org:gromacs
[gromacs/adressmacs.git] / include / tmpi.h
blobdfe627d840652a32239f4fb0e91b1f21b3fbd03a
1 /*
2 This source code file is part of thread_mpi.
3 Written by Sander Pronk, Erik Lindahl, and possibly others.
5 Copyright (c) 2009, Sander Pronk, Erik Lindahl.
6 All rights reserved.
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.
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.
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.
37 To help us fund development, we humbly ask that you cite
38 any papers on the package - you can find them in the top README file.
41 /*! \mainpage thread_mpi
43 thread_mpi is a cross-platform threading library for applications in
44 high-performance computing. It supports:
46 - Cross-platform thread primitives (thread creation, mutexes, spinlocks,
47 barriers, thread-local storage, etc.).
48 - Cross-platform atomic operations (compare-and-swap, add-return, etc) for
49 safe lock-free synchronization.
50 - An implementation of (currently, much of) MPI, either as a drop-in
51 replacement, or for use in conjunction with a networked MPI
52 implementation.
53 - Shared-memory allocation and memory management (planned, as of now).
54 - Basic lock-free data structures (planned, as of now).
56 Because it can be used as a drop-in replacement for MPI, existing codes
57 using MPI can start using thread_mpi without major changes in the
58 source code, assuming -- and this is a big assumption -- that the code
59 is thread-safe.
61 Alternatively, networked MPI calls can be used in conjunction with
62 thread_mpi calls (simply by using
63 "#include <thread_mpi.h>"
64 instead of
65 "#include <tmpi.h>"
66 and pre-fixing all thread_mpi MPI-like calls with tMPI instead of MPI.
68 The availability of both MPI calls and shared-memory constructs makes it
69 possible to transition (relatively) seamlessly from an MPI-style code
70 to code that's optimal on multicore CPUs.
72 Although MPI-style message passing isn't neccesarily optimal for
73 performance on shared-memory systems, the MPI communicator concept and
74 its emphasis on collective operations makes sense even when computing on
75 one machine with multiple cores. The communicator forms the basis for
76 the shared-memory allocation and lock-free data structure implementations
77 in thread_mpi.
79 Although usable as a stand-alone library, thread_mpi is designed to
80 be incorporated in the code tree, eliminating any external build
81 requirements. The BSD-style license that this library is distributed
82 with reflects this.
84 Thread primitives and the atomic operations are cpu and operating system
85 dependent - thread_mpi attempts to make them available with the same
86 interface independently of the platform it's run on.
87 Currently the thread primitives are supported on:
88 - any operating system supporting POSIX threads
89 - Windows (XP and later).
91 The atomic operations (such as compare-and-swap) are supported on:
92 - gcc on x86, x86_64, PowerPC and Itanium.
93 - Intel compilers on x86, x86_64 and Itanium.
94 - xlc on PowerPC.
95 - (partial) HP/UX compilers on Itanium.
97 Detailed descriptions of the parts of the API can be found in:
98 - thread_mpi/threads.h for the threading fundamentals.
99 - thread_mpi/atomic.h for the atomic operations.
100 - thread_mpi/tmpi.h for the MPI functions as tMPI_-prefixed functions.
101 - thread_mpi/mpi.h for the MPI bindings.
105 /** \file
107 * \brief Convenience header file for MPI compatibility.
109 * This file includes the tMPI header file thread_mpi/tmpi.h and the true
110 * MPI-style bindings of thread_mpi/mpi.h, as well as thread_mpi/threads.h and
111 * thread_mpi/atomic.h header files. If you'd like to use the components
112 * individually, or be able to use a networked MPI together with thread_mpi,
113 * include the relevant header files directly.
116 #include "thread_mpi/threads.h"
117 #include "thread_mpi/atomic.h"
118 #include "thread_mpi/tmpi.h"
119 #include "thread_mpi/mpi_bindings.h"