Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1.  
  2. #include <mpi.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #ifndef _EXTERN_C_
  7. #ifdef __cplusplus
  8. #define _EXTERN_C_ extern "C"
  9. #else /* __cplusplus */
  10. #define _EXTERN_C_
  11. #endif /* __cplusplus */
  12. #endif /* _EXTERN_C_ */
  13.  
  14. #ifdef MPICH_HAS_C2F
  15. _EXTERN_C_ void *MPIR_ToPointer(int);
  16. #endif // MPICH_HAS_C2F
  17.  
  18. #ifdef PIC
  19. /* For shared libraries, declare these weak and figure out which one was linked
  20. based on which init wrapper was called. See mpi_init wrappers. */
  21. #pragma weak pmpi_init
  22. #pragma weak PMPI_INIT
  23. #pragma weak pmpi_init_
  24. #pragma weak pmpi_init__
  25. #endif /* PIC */
  26.  
  27. _EXTERN_C_ void pmpi_init(MPI_Fint *ierr);
  28. _EXTERN_C_ void PMPI_INIT(MPI_Fint *ierr);
  29. _EXTERN_C_ void pmpi_init_(MPI_Fint *ierr);
  30. _EXTERN_C_ void pmpi_init__(MPI_Fint *ierr);
  31.  
  32. // #include <stdlib.h>
  33. // #include <stdio.h>
  34. #include <inttypes.h>
  35. // #include <mpi.h>
  36. #include <otf2/otf2.h>
  37. #if MPI_VERSION < 3
  38. #define OTF2_MPI_UINT64_T MPI_UNSIGNED_LONG
  39. #define OTF2_MPI_INT64_T MPI_LONG
  40. #endif
  41. #include <otf2/OTF2_MPI_Collectives.h>
  42.  
  43. bool is_init = false;
  44. OTF2_Archive* archive;
  45.  
  46. __attribute__((constructor)) void init(void)
  47. {
  48. if(!is_init)
  49. {
  50. archive = OTF2_Archive_Open( "./",
  51. "ArchiveTest",
  52. OTF2_FILEMODE_WRITE,
  53. 1024 * 1024 /* event chunk size */,
  54. 4 * 1024 * 1024 /* def chunk size */,
  55. OTF2_SUBSTRATE_POSIX,
  56. OTF2_COMPRESSION_NONE );
  57. is_init = true;
  58. }
  59. }
  60.  
  61. __attribute__((destructor)) void fini(void)
  62. {
  63. if(is_init)
  64. {
  65. OTF2_Archive_Close( archive );
  66. is_init = false;
  67. }
  68. }
  69.  
  70. /* ================== C Wrappers for MPI_Send ================== */
  71. _EXTERN_C_ int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm);
  72. _EXTERN_C_ int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
  73. int _wrap_py_return_val = 0;
  74. {
  75. _wrap_py_return_val = PMPI_Send(buf, count, datatype, dest, tag, comm);
  76. }
  77. return _wrap_py_return_val;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement