Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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.  
  33. // #include <stdlib.h>
  34. // #include <stdio.h>
  35. #include <inttypes.h>
  36. // #include <mpi.h>
  37. #include <otf2/otf2.h>
  38. #if MPI_VERSION < 3
  39. #define OTF2_MPI_UINT64_T MPI_UNSIGNED_LONG
  40. #define OTF2_MPI_INT64_T MPI_LONG
  41. #endif
  42. #include <otf2/OTF2_MPI_Collectives.h>
  43.  
  44. _EXTERN_C_ OTF2_Archive* OTF2_Archive_Open ( const char * archivePath,
  45. const char * archiveName,
  46. const OTF2_FileMode fileMode,
  47. const uint64_t chunkSizeEvents,
  48. const uint64_t chunkSizeDefs,
  49. const OTF2_FileSubstrate fileSubstrate,
  50. const OTF2_Compression compression
  51. );
  52. _EXTERN_C_ OTF2_ErrorCode OTF2_Archive_Close ( OTF2_Archive * archive );
  53.  
  54. bool is_init = false;
  55. OTF2_Archive* archive;
  56.  
  57. __attribute__((constructor)) void init(void)
  58. {
  59. if(!is_init)
  60. {
  61. archive = OTF2_Archive_Open( "./",
  62. "ArchiveTest",
  63. OTF2_FILEMODE_WRITE,
  64. 1024 * 1024 /* event chunk size */,
  65. 4 * 1024 * 1024 /* def chunk size */,
  66. OTF2_SUBSTRATE_POSIX,
  67. OTF2_COMPRESSION_NONE );
  68. is_init = true;
  69. }
  70. }
  71.  
  72. __attribute__((destructor)) void fini(void)
  73. {
  74. if(is_init)
  75. {
  76. OTF2_Archive_Close( archive );
  77. is_init = false;
  78. }
  79. }
  80.  
  81. /* ================== C Wrappers for MPI_Send ================== */
  82. _EXTERN_C_ int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm);
  83. _EXTERN_C_ int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
  84. int _wrap_py_return_val = 0;
  85. {
  86. _wrap_py_return_val = PMPI_Send(buf, count, datatype, dest, tag, comm);
  87. }
  88. return _wrap_py_return_val;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement