| [2aa6644] | 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 |
|
|---|
| 13 | /******************************************************************************
|
|---|
| 14 | *
|
|---|
| 15 | * Fake mpi stubs to generate serial codes without mpi
|
|---|
| 16 | *
|
|---|
| 17 | *****************************************************************************/
|
|---|
| 18 |
|
|---|
| 19 | #include "utilities.h"
|
|---|
| 20 |
|
|---|
| 21 | #ifdef HYPRE_USE_PTHREADS
|
|---|
| 22 |
|
|---|
| 23 | #define HYPRE_USING_THREAD_MPISTUBS
|
|---|
| 24 |
|
|---|
| 25 | int
|
|---|
| 26 | hypre_thread_MPI_Init( int *argc,
|
|---|
| 27 | char ***argv)
|
|---|
| 28 | {
|
|---|
| 29 | int returnval;
|
|---|
| 30 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 31 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 32 | if (I_call_mpi)
|
|---|
| 33 | {
|
|---|
| 34 | returnval=MPI_Init(argc,argv);
|
|---|
| 35 | }
|
|---|
| 36 | else
|
|---|
| 37 | {
|
|---|
| 38 | returnval=0;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | return returnval;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | double
|
|---|
| 45 | hypre_thread_MPI_Wtime( )
|
|---|
| 46 | {
|
|---|
| 47 | double returnval;
|
|---|
| 48 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 49 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 50 | if (I_call_mpi)
|
|---|
| 51 | {
|
|---|
| 52 | returnval=MPI_Wtime();
|
|---|
| 53 | }
|
|---|
| 54 | else
|
|---|
| 55 | {
|
|---|
| 56 | returnval=0.0;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | return returnval;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | double
|
|---|
| 63 | hypre_thread_MPI_Wtick( )
|
|---|
| 64 | {
|
|---|
| 65 | double returnval;
|
|---|
| 66 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 67 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 68 | if (I_call_mpi)
|
|---|
| 69 | {
|
|---|
| 70 | returnval=MPI_Wtick();
|
|---|
| 71 | }
|
|---|
| 72 | else
|
|---|
| 73 | {
|
|---|
| 74 | returnval=0.0;
|
|---|
| 75 | }
|
|---|
| 76 | return returnval;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | int
|
|---|
| 80 | hypre_thread_MPI_Barrier( MPI_Comm comm )
|
|---|
| 81 | {
|
|---|
| 82 | int returnval;
|
|---|
| 83 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 84 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 85 | if (I_call_mpi)
|
|---|
| 86 | {
|
|---|
| 87 | returnval=MPI_Barrier(comm);
|
|---|
| 88 | }
|
|---|
| 89 | else
|
|---|
| 90 | {
|
|---|
| 91 | returnval=0;
|
|---|
| 92 | }
|
|---|
| 93 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 94 | return returnval;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | int
|
|---|
| 98 | hypre_thread_MPI_Finalize( )
|
|---|
| 99 | {
|
|---|
| 100 | int returnval;
|
|---|
| 101 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 102 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 103 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 104 | if (I_call_mpi)
|
|---|
| 105 | {
|
|---|
| 106 | returnval=MPI_Finalize();
|
|---|
| 107 | }
|
|---|
| 108 | else
|
|---|
| 109 | {
|
|---|
| 110 | returnval=0;
|
|---|
| 111 | }
|
|---|
| 112 | return returnval;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | int
|
|---|
| 116 | hypre_thread_MPI_Comm_group( MPI_Comm comm,
|
|---|
| 117 | MPI_Group *group )
|
|---|
| 118 | {
|
|---|
| 119 | int returnval;
|
|---|
| 120 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 121 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 122 | if (I_call_mpi)
|
|---|
| 123 | {
|
|---|
| 124 | returnval=MPI_Comm_group(comm,group );
|
|---|
| 125 | }
|
|---|
| 126 | else
|
|---|
| 127 | {
|
|---|
| 128 | returnval=0;
|
|---|
| 129 | }
|
|---|
| 130 | return returnval;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | int
|
|---|
| 134 | hypre_thread_MPI_Comm_dup( MPI_Comm comm,
|
|---|
| 135 | MPI_Comm *newcomm )
|
|---|
| 136 | {
|
|---|
| 137 | int returnval;
|
|---|
| 138 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 139 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 140 | if (I_call_mpi)
|
|---|
| 141 | {
|
|---|
| 142 | returnval=MPI_Comm_dup(comm,newcomm);
|
|---|
| 143 | }
|
|---|
| 144 | else
|
|---|
| 145 | {
|
|---|
| 146 | returnval=0;
|
|---|
| 147 | }
|
|---|
| 148 | return returnval;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | int
|
|---|
| 152 | hypre_thread_MPI_Group_incl( MPI_Group group,
|
|---|
| 153 | int n,
|
|---|
| 154 | int *ranks,
|
|---|
| 155 | MPI_Group *newgroup )
|
|---|
| 156 | {
|
|---|
| 157 | int returnval;
|
|---|
| 158 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 159 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 160 | if (I_call_mpi)
|
|---|
| 161 | {
|
|---|
| 162 | returnval=MPI_Group_incl(group,n,ranks,newgroup );
|
|---|
| 163 | }
|
|---|
| 164 | else
|
|---|
| 165 | {
|
|---|
| 166 | returnval=0;
|
|---|
| 167 | }
|
|---|
| 168 | return returnval;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | int
|
|---|
| 172 | hypre_thread_MPI_Comm_create( MPI_Comm comm,
|
|---|
| 173 | MPI_Group group,
|
|---|
| 174 | MPI_Comm *newcomm )
|
|---|
| 175 | {
|
|---|
| 176 | int returnval;
|
|---|
| 177 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 178 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 179 | if (I_call_mpi)
|
|---|
| 180 | {
|
|---|
| 181 | returnval=MPI_Comm_create(comm,group,newcomm );
|
|---|
| 182 | }
|
|---|
| 183 | else
|
|---|
| 184 | {
|
|---|
| 185 | returnval=0;
|
|---|
| 186 | }
|
|---|
| 187 | return returnval;
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | int
|
|---|
| 191 | hypre_thread_MPI_Allgather( void *sendbuf,
|
|---|
| 192 | int sendcount,
|
|---|
| 193 | MPI_Datatype sendtype,
|
|---|
| 194 | void *recvbuf,
|
|---|
| 195 | int recvcount,
|
|---|
| 196 | MPI_Datatype recvtype,
|
|---|
| 197 | MPI_Comm comm )
|
|---|
| 198 | {
|
|---|
| 199 | int returnval;
|
|---|
| 200 | int i;
|
|---|
| 201 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 202 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 203 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 204 | if (I_call_mpi)
|
|---|
| 205 | {
|
|---|
| 206 | returnval=MPI_Allgather(sendbuf,sendcount,sendtype,recvbuf,recvcount,
|
|---|
| 207 | recvtype,comm);
|
|---|
| 208 | }
|
|---|
| 209 | else
|
|---|
| 210 | {
|
|---|
| 211 | returnval=0;
|
|---|
| 212 | }
|
|---|
| 213 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 214 | return returnval;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | int
|
|---|
| 218 | hypre_thread_MPI_Allgatherv( void *sendbuf,
|
|---|
| 219 | int sendcount,
|
|---|
| 220 | MPI_Datatype sendtype,
|
|---|
| 221 | void *recvbuf,
|
|---|
| 222 | int *recvcounts,
|
|---|
| 223 | int *displs,
|
|---|
| 224 | MPI_Datatype recvtype,
|
|---|
| 225 | MPI_Comm comm )
|
|---|
| 226 | {
|
|---|
| 227 | int i,returnval;
|
|---|
| 228 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 229 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 230 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 231 | if (I_call_mpi)
|
|---|
| 232 | {
|
|---|
| 233 | returnval=MPI_Allgatherv(sendbuf,sendcount,sendtype,recvbuf,recvcounts,
|
|---|
| 234 | displs,recvtype,comm);
|
|---|
| 235 | }
|
|---|
| 236 | else
|
|---|
| 237 | {
|
|---|
| 238 | returnval=0;
|
|---|
| 239 | }
|
|---|
| 240 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 241 | return returnval;
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | int
|
|---|
| 245 | hypre_thread_MPI_Bcast( void *buffer,
|
|---|
| 246 | int count,
|
|---|
| 247 | MPI_Datatype datatype,
|
|---|
| 248 | int root,
|
|---|
| 249 | MPI_Comm comm )
|
|---|
| 250 | {
|
|---|
| 251 | int returnval;
|
|---|
| 252 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 253 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 254 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 255 | if (I_call_mpi)
|
|---|
| 256 | {
|
|---|
| 257 | returnval=MPI_Bcast(buffer,count,datatype,root,comm);
|
|---|
| 258 | }
|
|---|
| 259 | else
|
|---|
| 260 | {
|
|---|
| 261 | returnval=0;
|
|---|
| 262 | }
|
|---|
| 263 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 264 | return returnval;
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | int
|
|---|
| 268 | hypre_thread_MPI_Send( void *buf,
|
|---|
| 269 | int count,
|
|---|
| 270 | MPI_Datatype datatype,
|
|---|
| 271 | int dest,
|
|---|
| 272 | int tag,
|
|---|
| 273 | MPI_Comm comm )
|
|---|
| 274 | {
|
|---|
| 275 | int returnval;
|
|---|
| 276 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 277 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 278 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 279 | if (I_call_mpi)
|
|---|
| 280 | {
|
|---|
| 281 | returnval=MPI_Send(buf,count,datatype,dest,tag,comm);
|
|---|
| 282 | }
|
|---|
| 283 | else
|
|---|
| 284 | {
|
|---|
| 285 | returnval=0;
|
|---|
| 286 | }
|
|---|
| 287 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 288 | return returnval;
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | int
|
|---|
| 292 | hypre_thread_MPI_Recv( void *buf,
|
|---|
| 293 | int count,
|
|---|
| 294 | MPI_Datatype datatype,
|
|---|
| 295 | int source,
|
|---|
| 296 | int tag,
|
|---|
| 297 | MPI_Comm comm,
|
|---|
| 298 | MPI_Status *status )
|
|---|
| 299 | {
|
|---|
| 300 | int returnval;
|
|---|
| 301 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 302 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 303 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 304 | if (I_call_mpi)
|
|---|
| 305 | {
|
|---|
| 306 | returnval=MPI_Recv(buf,count,datatype,source,tag,comm,status);
|
|---|
| 307 | }
|
|---|
| 308 | else
|
|---|
| 309 | {
|
|---|
| 310 | returnval=0;
|
|---|
| 311 | }
|
|---|
| 312 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 313 | return returnval;
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | int
|
|---|
| 317 | hypre_thread_MPI_Isend( void *buf,
|
|---|
| 318 | int count,
|
|---|
| 319 | MPI_Datatype datatype,
|
|---|
| 320 | int dest,
|
|---|
| 321 | int tag,
|
|---|
| 322 | MPI_Comm comm,
|
|---|
| 323 | MPI_Request *request )
|
|---|
| 324 | {
|
|---|
| 325 | int returnval;
|
|---|
| 326 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 327 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 328 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 329 | if (I_call_mpi)
|
|---|
| 330 | {
|
|---|
| 331 | returnval=MPI_Isend(buf,count,datatype,dest,tag,comm,request);
|
|---|
| 332 | }
|
|---|
| 333 | else
|
|---|
| 334 | {
|
|---|
| 335 | returnval=0;
|
|---|
| 336 | }
|
|---|
| 337 | return returnval;
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | int
|
|---|
| 341 | hypre_thread_MPI_Irecv( void *buf,
|
|---|
| 342 | int count,
|
|---|
| 343 | MPI_Datatype datatype,
|
|---|
| 344 | int source,
|
|---|
| 345 | int tag,
|
|---|
| 346 | MPI_Comm comm,
|
|---|
| 347 | MPI_Request *request )
|
|---|
| 348 | {
|
|---|
| 349 | int returnval;
|
|---|
| 350 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 351 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 352 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 353 | if (I_call_mpi)
|
|---|
| 354 | {
|
|---|
| 355 | returnval=MPI_Irecv(buf,count,datatype,source,tag,comm,request);
|
|---|
| 356 | }
|
|---|
| 357 | else
|
|---|
| 358 | {
|
|---|
| 359 | returnval=0;
|
|---|
| 360 | }
|
|---|
| 361 | return returnval;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | int
|
|---|
| 365 | hypre_thread_MPI_Wait( MPI_Request *request,
|
|---|
| 366 | MPI_Status *status )
|
|---|
| 367 | {
|
|---|
| 368 | int returnval;
|
|---|
| 369 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 370 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 371 | if (I_call_mpi)
|
|---|
| 372 | {
|
|---|
| 373 | returnval=MPI_Wait(request,status);
|
|---|
| 374 | }
|
|---|
| 375 | else
|
|---|
| 376 | {
|
|---|
| 377 | returnval=0;
|
|---|
| 378 | }
|
|---|
| 379 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 380 | return returnval;
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | int
|
|---|
| 384 | hypre_thread_MPI_Waitall( int count,
|
|---|
| 385 | MPI_Request *array_of_requests,
|
|---|
| 386 | MPI_Status *array_of_statuses )
|
|---|
| 387 | {
|
|---|
| 388 | int returnval;
|
|---|
| 389 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 390 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 391 | if (I_call_mpi)
|
|---|
| 392 | {
|
|---|
| 393 | returnval=MPI_Waitall(count,array_of_requests,array_of_statuses);
|
|---|
| 394 | }
|
|---|
| 395 | else
|
|---|
| 396 | {
|
|---|
| 397 | returnval=0;
|
|---|
| 398 | }
|
|---|
| 399 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 400 | return returnval;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | int
|
|---|
| 404 | hypre_thread_MPI_Waitany( int count,
|
|---|
| 405 | MPI_Request *array_of_requests,
|
|---|
| 406 | int *index,
|
|---|
| 407 | MPI_Status *status )
|
|---|
| 408 | {
|
|---|
| 409 | int returnval;
|
|---|
| 410 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 411 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 412 | if (I_call_mpi)
|
|---|
| 413 | {
|
|---|
| 414 | returnval=MPI_Waitany(count,array_of_requests,index,status);
|
|---|
| 415 | }
|
|---|
| 416 | else
|
|---|
| 417 | {
|
|---|
| 418 | returnval=0;
|
|---|
| 419 | }
|
|---|
| 420 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 421 | return returnval;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | int
|
|---|
| 425 | hypre_thread_MPI_Comm_size( MPI_Comm comm,
|
|---|
| 426 | int *size )
|
|---|
| 427 | {
|
|---|
| 428 | int returnval;
|
|---|
| 429 |
|
|---|
| 430 | pthread_mutex_lock(&mpi_mtx);
|
|---|
| 431 | returnval=MPI_Comm_size(comm,size);
|
|---|
| 432 | pthread_mutex_unlock(&mpi_mtx);
|
|---|
| 433 | return returnval;
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | int
|
|---|
| 437 | hypre_thread_MPI_Comm_rank( MPI_Comm comm,
|
|---|
| 438 | int *rank )
|
|---|
| 439 | {
|
|---|
| 440 | int returnval;
|
|---|
| 441 |
|
|---|
| 442 | pthread_mutex_lock(&mpi_mtx);
|
|---|
| 443 | returnval=MPI_Comm_rank(comm,rank);
|
|---|
| 444 | pthread_mutex_unlock(&mpi_mtx);
|
|---|
| 445 |
|
|---|
| 446 | return returnval;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | int
|
|---|
| 450 | hypre_thread_MPI_Allreduce( void *sendbuf,
|
|---|
| 451 | void *recvbuf,
|
|---|
| 452 | int count,
|
|---|
| 453 | MPI_Datatype datatype,
|
|---|
| 454 | MPI_Op op,
|
|---|
| 455 | MPI_Comm comm )
|
|---|
| 456 | {
|
|---|
| 457 | int returnval;
|
|---|
| 458 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 459 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 460 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 461 | if (I_call_mpi)
|
|---|
| 462 | {
|
|---|
| 463 | returnval=MPI_Allreduce(sendbuf,recvbuf,count,datatype,op,comm);
|
|---|
| 464 | }
|
|---|
| 465 | else
|
|---|
| 466 | {
|
|---|
| 467 | returnval=0;
|
|---|
| 468 | }
|
|---|
| 469 | hypre_barrier(&mpi_mtx, unthreaded);
|
|---|
| 470 | return returnval;
|
|---|
| 471 | }
|
|---|
| 472 |
|
|---|
| 473 | int
|
|---|
| 474 | hypre_thread_MPI_Type_hvector( int count,
|
|---|
| 475 | int blocklength,
|
|---|
| 476 | MPI_Aint stride,
|
|---|
| 477 | MPI_Datatype oldtype,
|
|---|
| 478 | MPI_Datatype *newtype )
|
|---|
| 479 | {
|
|---|
| 480 | int returnval;
|
|---|
| 481 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 482 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 483 | if (I_call_mpi)
|
|---|
| 484 | {
|
|---|
| 485 | returnval=MPI_Type_hvector(count,blocklength,stride,oldtype,newtype);
|
|---|
| 486 | }
|
|---|
| 487 | else
|
|---|
| 488 | {
|
|---|
| 489 | returnval=0;
|
|---|
| 490 | }
|
|---|
| 491 | return returnval;
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | int
|
|---|
| 495 | hypre_thread_MPI_Type_struct( int count,
|
|---|
| 496 | int *array_of_blocklengths,
|
|---|
| 497 | MPI_Aint *array_of_displacements,
|
|---|
| 498 | MPI_Datatype *array_of_types,
|
|---|
| 499 | MPI_Datatype *newtype )
|
|---|
| 500 | {
|
|---|
| 501 | int returnval;
|
|---|
| 502 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 503 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 504 | if (I_call_mpi)
|
|---|
| 505 | {
|
|---|
| 506 | returnval=MPI_Type_struct(count,array_of_blocklengths,array_of_displacements,
|
|---|
| 507 | array_of_types,newtype);
|
|---|
| 508 | }
|
|---|
| 509 | else
|
|---|
| 510 | {
|
|---|
| 511 | returnval=0;
|
|---|
| 512 | }
|
|---|
| 513 | return returnval;
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | int
|
|---|
| 517 | hypre_thread_MPI_Type_free( MPI_Datatype *datatype )
|
|---|
| 518 | {
|
|---|
| 519 | int returnval;
|
|---|
| 520 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 521 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 522 | if (I_call_mpi)
|
|---|
| 523 | {
|
|---|
| 524 | returnval=MPI_Type_free(datatype);
|
|---|
| 525 | }
|
|---|
| 526 | else
|
|---|
| 527 | {
|
|---|
| 528 | returnval=0;
|
|---|
| 529 | }
|
|---|
| 530 | return returnval;
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | int
|
|---|
| 534 | hypre_thread_MPI_Type_commit( MPI_Datatype *datatype )
|
|---|
| 535 | {
|
|---|
| 536 | int returnval;
|
|---|
| 537 | int unthreaded = pthread_equal(initial_thread,pthread_self());
|
|---|
| 538 | int I_call_mpi = unthreaded || pthread_equal(hypre_thread[0],pthread_self());
|
|---|
| 539 | if (I_call_mpi)
|
|---|
| 540 | {
|
|---|
| 541 | returnval=MPI_Type_commit(datatype);
|
|---|
| 542 | }
|
|---|
| 543 | else
|
|---|
| 544 | {
|
|---|
| 545 | returnval=0;
|
|---|
| 546 | }
|
|---|
| 547 | return returnval;
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | #else
|
|---|
| 551 |
|
|---|
| 552 | /* this is used only to eliminate compiler warnings */
|
|---|
| 553 | int hypre_empty3;
|
|---|
| 554 |
|
|---|
| 555 | #endif
|
|---|