Made g_protonate (partially) work.
[gromacs/rigid-bodies.git] / include / tmpi.h
blob1a660bc2218e711ab36f84c0fe6d701ccc3e2eee
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.
39 /*!
40 \if THREAD_MPI_MAIN
41 \mainpage thread_mpi thread_mpi threading library
42 \else
43 \page thread_mpi thread_mpi threading library
44 \endif
46 thread_mpi is a cross-platform threading library for applications in
47 high-performance computing. It supports:
49 - Cross-platform thread primitives (thread creation, mutexes, spinlocks,
50 barriers, thread-local storage, etc.).
51 - Cross-platform atomic operations (compare-and-swap, add-return, etc) for
52 safe lock-free synchronization.
53 - An implementation of (currently, much of) MPI, either as a drop-in
54 replacement, or for use in conjunction with a networked MPI
55 implementation.
56 - Shared-memory allocation and memory management (planned, as of now).
57 - Basic lock-free data structures (planned, as of now).
59 Because it can be used as a drop-in replacement for MPI, existing codes
60 using MPI can start using thread_mpi without major changes in the
61 source code, assuming -- and this is a big assumption -- that the code
62 is thread-safe.
64 Alternatively, networked MPI calls can be used in conjunction with
65 thread_mpi calls (simply by using
66 "#include <thread_mpi.h>"
67 instead of
68 "#include <tmpi.h>"
69 and pre-fixing all thread_mpi MPI-like calls with tMPI instead of MPI.
71 The availability of both MPI calls and shared-memory constructs makes it
72 possible to transition (relatively) seamlessly from an MPI-style code
73 to code that's optimal on multicore CPUs.
75 Although MPI-style message passing isn't neccesarily optimal for
76 performance on shared-memory systems, the MPI communicator concept and
77 its emphasis on collective operations makes sense even when computing on
78 one machine with multiple cores. The communicator forms the basis for
79 the shared-memory allocation and lock-free data structure implementations
80 in thread_mpi.
82 Although usable as a stand-alone library, thread_mpi is designed to
83 be incorporated in the code tree, eliminating any external build
84 requirements. The BSD-style license that this library is distributed
85 with reflects this.
87 Thread primitives and the atomic operations are cpu and operating system
88 dependent - thread_mpi attempts to make them available with the same
89 interface independently of the platform it's run on.
90 Currently the thread primitives are supported on:
91 - any operating system supporting POSIX threads
92 - Windows (XP and later).
94 The atomic operations (such as compare-and-swap) are supported on:
95 - gcc on x86, x86_64, PowerPC and Itanium.
96 - Intel compilers on x86, x86_64 and Itanium.
97 - xlc on PowerPC.
98 - (partial) HP/UX compilers on Itanium.
100 Detailed descriptions of the parts of the API can be found in:
101 - thread_mpi/threads.h for threading fundamentals.
102 - thread_mpi/atomic.h for atomic operations.
103 - thread_mpi/tmpi.h for the MPI functions as tMPI_-prefixed functions.
104 - thread_mpi/mpi_bindings.h for the MPI bindings.
108 /** \file
110 * \brief Convenience header file for MPI compatibility.
112 * This file includes the tMPI header file thread_mpi/tmpi.h and the true
113 * MPI-style bindings of thread_mpi/mpi.h, as well as thread_mpi/threads.h and
114 * thread_mpi/atomic.h header files. If you'd like to use the components
115 * individually, or be able to use a networked MPI together with thread_mpi,
116 * include the relevant header files directly.
120 #include "thread_mpi/atomic.h"
121 #include "thread_mpi/threads.h"
122 #include "thread_mpi/barrier.h"
123 #include "thread_mpi/event.h"
124 #include "thread_mpi/lock.h"
125 #include "thread_mpi/tmpi.h"
126 #include "thread_mpi/collective.h"
127 #include "thread_mpi/hwinfo.h"
129 #include "thread_mpi/mpi_bindings.h"