MULTI-THREADED OBJECT- ORIENTED MPI-BASED MESSAGE PASSING INTERFACE: The ARCH Library THE KLUWER INTERNATIONAL SERIES IN ENGINEERING AND COMPUTER SCIENCE MULTI-THREADED OBJECT- ORIENTED MPI-BASED MESSAGE PASSING INTERFACE: The ARCH Library by Jean-Marc Adamo Universite Claude-Bernard de Lyon Ecole Superieure de Chimie, Physique et Electronique France Springer Science+Business Media, LLC Library of Congress Cataloging-in-Publication Data A C.I.P. Catalogue record for this book is available from the Library of Congress. ISBN 978-1-4613-7640-8 ISBN 978-1-4615-5761-6 (eBook) DOI 10.1007/978-1-4615-5761-6 Copyright © 1998 by Springer Science+Business Media New York Originally published by Kluwer Academic Publishers in 1998 Softcover reprint of the hardcover 1s t edition 1998 AU rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, mechanical, photo copying, recording, or otherwise, without the prior written permission of the publisher, Springer Science+Business Media, LLC Printed on acid-free paper. I TABLE OF CONTENTS TABLE OF CONTENTS ........................................................................................ V PREFACE ............•.•.......•...•.........•...........•..........................•...•.....•.•........•....•.•.•.••.. XI CHAPTER!. IN'TRODUCTION .................................................................................................... 1 1.1. THEMPI LmRARY ...................................................................................... l 1.1.1. MPI-I ................................................................................................ 1 1.1.2. MPI-2 ................................................................................................ 3 1.2. ARCH ......................................................................................................... 3 1.3. AN OVERVIEW OF ARCH ............................................................................ 4 1.3.1. Threads ............................................................................................... 4 1.3.2. Thread Synchronous Point-to-point Communication ......................... 5 1.3.3. Thread Asynchronous Point-to-point Communication ....................... 5 1.3.4. Thread One-sided Communication ..................................................... 6 1.3.5. Global Pointers and Spread Arrays ................................................... 7 CHAPTER2. THREADS -CONCURRENCY .............................................................................. 9 2.1. THREADS ..................................................................................................... 9 Example 1 .................................................................................................................. 10 2.1.1. Constructor ....................................................................................... 10 Example 2 .................................................................................................................. 11 2.1.2. Setup ................................................................................................. 11 Example 3 .................................................................................................................. 11 2.1.3. Schedule ........................................................................................... 12 2.1.4. Synchronized Execution .................................................................... 13 Example 4 .................................................................................................................. 13 2.1.5. Reschedule ........................................................................................ 14 2.1.6. Stop ................................................................................................... 15 2.2. S_THREADS .............................................................................................. 15 Constructor. ...................................................................................................... 15 2.3. COMMUNICATION BETWEEN SON AND FATHER ......................................... 15 2.4. STATE-TRANSITION DIAGRAM .................................................................. 16 2.5. ARCH PROGRAM ORGANIZATION ............................................................ 16 2.5.1. Predefined Variables and Functions ................................................ 17 2.5.2. The MAIN Macro .............................................................................. 17 2.5.3. Start Maintain and Terminate .......................................................... 18 2.5.4. Polling .............................................................................................. 19 2.5.5. Use-defined Events ........................................................................... 20 vi TABLE OF CONTENTS 2.5.6. Flushing ............................................................................................ 21 2.5.7. Switching .......................................................................................... 22 CHAPTER3. SYNCHRONOUS POINT· TO·POINT COMMUNICATION ........................... 2S 3.1. CHANNEL CLASS ORGANIZATION ............................................................. 25 3.2. LOCAL CHANNELS .................................................................................... 26 Protocol I .................................................................................................................. 26 3.2.1. ChanL Type Channels ...................................................................... 26 Constructor ................................................................................................................ 26 Synchronization ......................................................................................................... 26 3.2.2. ChanW Type Channels ................................................................... 26 Constructor ................................................................................................................ 27 Reset .......................................................................................................................... 27 Communication ......................................................................................................... 27 Status Request ........................................................................................................... 27 Example I .................................................................................................................. 27 3.3. INTER-PROCESS CHANNELS ...................................................................... 29 Example 2 .................................................................................................................. 29 3.3.1. ChanR Type Channels ...................................................................... 31 Construction .............................................................................................................. 31 Constructors: ......................................................................................................... 31 Collective Synchronization of ChanR Constructors .............................................. 32 Setting. ....................................................................................................................... 32 Inter-process Synchronization ................................................................................... 32 Protocol 2 .................................................................................................................. 33 Tag Related Requests ................................................................................................ 33 Source and Destination Process Related Request ...................................................... 34 Communicator Related Request ................................................................................ 34 3.3.2. ChanRD Type Channels ................................................................... 34 Constructor ................................................................................................................ 34 Setting ........................................................................................................................ 34 Synchronization-Communication .............................................................................. 35 Protocol 3 .................................................................................................................. 35 Status Related Requests ............................................................................................. 35 Tag Related Requests ................................................................................................ 36 Source and Destination Process Requests .................................................................. 36 Communicator Related Request ................................................................................ 36 3.4. NON-DETERMINISTIC MANY WAY RECEPTION .......................................... 36 3.4.1. Basic Behavior ................................................................................. 36 3.4.2. Extensions ......................................................................................... 37 3.4.3. Function alt ...................................................................................... 37 Protocol 4: ................................................................................................................. 38 3.4.4. Ports to the alt Function ................................................................... 38 AltL class ................................................................................................................... 39 Constructors .......................................................................................................... 39 Setting ................................................................................................................... 40 Protocol 5: ............................................................................................................. 40 AltLDrecv Class ........................................................................................................ 40 Constructor ............................................................................................................ 40 THE ARCH UBRARY vii Setting ................................................................................................................... 41 Protocol 6: ............................................................................................................. 42 AltR Class .................................................................................................................. 42 Protocol 7: ............................................................................................................. 43 AltRDrecv Class ........................................................................................................ 43 Protocol 8: ............................................................................................................. 44 Example 3 ............................................................................................................. 44 Example 4 ............................................................................................................. 45 Example 5 ............................................................................................................. 45 3.5. ATOMICITY ............................................................................................... 46 CHAPTER4. ASYNCHRONOUS POINT· TO·POINT COMMUNICATION ........................ 47 4.1. ASYNCHRONOUS VERSUS SYNCHRONOUS .............................................•.. 47 4.2. CHANNELS FOR ASYNCHRONOUS POINT-TO-POINT COMMUNICATION ...... 49 4.2.1. Send and Receive Gates .................................................................... 49 4.2.2. Channel Construction and Setting .................................................... 50 Constructors ............................................................................................................... 50 Setting ........................................................................................................................ 51 Collective Synchronization of ChanA Constructors .................................................. 52 4.3. ASYNCHRONOUS COMMUNICATION FuNCTIONS ....................................... 54 4.3.1. Communication Functions ................................................................ 54 4.3.2. Completion Handling ....................................................................... 55 4.3.3. Probing ............................................................................................. 59 Probing One Asynchronous Channel ......................................................................... 59 Probing Any Asynchronous Channel ........................................................................ 59 CHAPTERS. GLOBAL DATA· ONE·SIDED COMMUNICATION. ..................................... 61 5.1. MOTIVATION .............................................................................................. 61 5.2. OUTLINE ................................................................................................... 63 5.3. THE CLASS GLOBAL .................................................................................. 65 5.3.1. Global Data Construction and Duplication ..................................... 65 General Constructors ................................................................................................. 65 Collective Synchronization of Global Constructors .................................................. 66 Global Identifiers ....................................................................................................... 66 Special Constructor for Tag O-Related Global Data .................................................. 67 Void Constructor ....................................................................................................... 67 Duplicator .................................................................................................................. 67 5.3.2. Setting Previously defined Global.. .................................................. 67 5.3.3. Requesting Tag Information ............................................................. 68 5.3.4. Requesting Handle Information ....................................................... 68 5.3.5. Requesting the Communicator or group .......................................... 69 5.3.6. Global Write and Read Functions .................................................... 69 Global Function Types .............................................................................................. 69 Blocking Write and Read ...................................................................................... 70 Non-blocking Write and Read ............................................................................... 71 Call-side completion Handler ................................................................................ 72 Target side Processing ............................................................................................... 74 Address Calculation .................................................................. " .......................... 74 viii TABLE OF CONTENTS Target-side Completion Handler ........................................................................... 76 Communication-Synchronization Protocols .............................................................. 76 Blocking and Non-Blocking Global Write: Protocol I ......................................... 76 Blocking and Non-Blocking Global Read: Protocol 2 .......................................... 78 Atomicity ................................................................................................................... 79 5.3.7. Tag 0 Related Global Data ............................................................... 79 5.4. EXAMPLE .................................................................................................. 79 5.4.1. Communication Class ....................................................................... 79 5.4.2. Postal Service: Send Component ...................................................... 80 5.4.3. Postal Service: Receive Component ................................................. 82 CHAPTER6. GLOBAL COMPLETION DETECTION ........................................................... 85 6.1. PROBLEM SETTING .................................................................................... 85 6.2. DETECTING COMPLETION VIA COUNTING ................................................. 85 6.3. IMPLEMENTING COUNTERS ALGORITHM ................................................... 87 6.4. ARCH IMPLEMENTATION OF COUNTERS ALGORITHM .............................. 88 6.4.1. Architecture ...................................................................................... 88 6.4.2. GC_monitor ...................................................................................... 90 6.4.3. Message Carrier Service .................................................................. 94 6.4.4. Communication Interfaces ................................................................ 96 6.4.5. Send_monitor. ................................................................................... 98 6.4.6. Recv_monitor. ................................................................................. 101 6.4.7. Probe_monitor. ............................................................................... 103 CHAPTER 7. DISTRIBUTED MUTUAL EXCLUSION ......................................................... 109 7.1. PROBLEM SETTING .................................................................................. 109 7.2. ALGORITHM FOR DISTRIBUTED MUTUAL EXCLUSION ............................ 109 7.2.1. UserStatus ..................................................................................... l09 7.2.2. Algorithm Philosophy ..................................................................... 110 7.2.3. Appending to the Queue ................................................................. 110 7.2.4. Limit Case ....................................................................................... 110 7.2.5. Algorithm Specification .................................................................. III 7.3. ARCH-BASED IMPLEMENTATION ............................................................ 112 7.3.1. MX_monitor. ................................................................................... 112 7.3.2. Communication Interfaces .............................................................. 114 7.3.3. Message Keeper. ............................................................................. 114 7.3.4. Implementing Distributed Mutual Exclusion: mx_engine .............. 115 CHAPTER 8. PARALLEL A* ALGORITHM. ......................................................................... 117 8.1. SEQUENTIAL A * ALGORITHM ................................................................. 117 Sequential Algorithm ...................................................................................... 118 8.2. A* PARALLEL IMPLEMENTATION ............................................................ 11 9 8.2.1. Quantitative Load Balancing ......................................................... 119 8.2.2. Qualitative Load Balancing ........................................................... 120 THE ARCH LIBRARY IX 8.2.3. Startup ............................................................................................ 121 8.2.4. ARCH-based 1mplementation ......................................................... 121 8.2.5. Experimental Results ...................................................................... 123 CHAPTER9. GLOBAL POINTERS· SPREAD ARRAYS ..................................................... 127 9.1. GLOBAL POINTERS .................................................................................. 128 9.1.1. Global Pointer Data Members ....................................................... 128 9.1.2. Global Pointer Construction .......................................................... 129 Construction by Member Enumeration .................................................................... 129 Construction by Duplication .................................................................................... 129 Construction of Tag-O related Global Pointers ........................................................ 129 Construction of Empty Global Pointers ................................................................... 130 9.1.3. RWCtrl record ................................................................................ 130 Example ................................................................................................................... 131 9.1.4. Global Pointer Operators ............................................................... 132 Class System Architecture ....................................................................................... 133 Comparison Operators ............................................................................................. 134 Semantics for G-typed Global Pointers ............................................................... 135 Semantics for S-typed Global Pointers ................................................................ 136 Arithmetic Operators ............................................................................................... 136 Assignment to Global Pointer .................................................................................. 136 Ref Type .................................................................................................................. 137 Dereferencing ...................................................................................................... 137 Indexing .............................................................................................................. 137 Assignment .............................................................................................................. 137 First Instance ....................................................................................................... 138 Second Instance .................................................................................................... 138 Global Write and Read Functions ............................................................................ 140 9.1.5. Setting and Getting Global Pointer Data Members ....................... 140 9.2. SPREAD ARRAYS ..................................................................................... 144 Spreading rule .......................................................................................................... 144 Example ................................................................................................................... 144 9.2.1. Spread Array Construction ............................................................. 144 9.2.2. Setting and Getting Spread Array Information .............................. 146 9.2.3. Illustrations .................................................................................... 146 Spread Images as SpreadArrays .............................................................................. 146 Spread Quadtrees as SpreadArrays .......................................................................... 148 Spread Triangular Matrices ..................................................................................... 150 CHAPTER 10. IMAGE SEGMENTATION ................................................................................ 151 10.1. REGION GROWING: SEQUENTIAL ALGORITHM .................................... 151 10.2. PARALLEL REGION GROWING ............................................................. 153 10.2.1. Image Splitting ............................................................................... 154 Spread Image ........................................................................................................... 154 Spread Quadtree ...................................................................................................... 155 10.2.2. Quadtree to Connectivity -Graph Transformation ........................ 155 Load Balancing ........................................................................................................ 155 From Leaf to Vertex ................................................................................................ 156 x TABLE OF CONTENTS 10.2.3. Connectivity-Graph Reduction ....................................................... 159 Spread Connectivity Graph ...................................................................................... 159 Parallel Graph Reduction ......................................................................................... 161 Selecting a Vertex ............................................................................................... 162 Collecting Matching Vertices .............................................................................. 162 Changing Links from Absorbed-to-Absorbing Vertices in Vertex Descriptors ... 162 Performing Vertex Reduction ............................................................................. 163 Updating minimum and maximum pixel values .................................................. 163 ARCH Code Sample: Collecting Matching Vertices ............................................... 164 Procedure collect_matchin~ vertices .................................................................. 164 Location Function Locate_x_rcd ......................................................................... 166 Completion Handler upon_RW _completion2 ..................................................... 166 10.2.4. Merge Tree ..................................................................................... 167 10.3. EXPERIMENTAL RESULTS .................................................................... 16 9 REFERENCES ..................................................................................................... 175 INDEX ................................................................................................................... 179
Description: