-
Notifications
You must be signed in to change notification settings - Fork 65
Pcu object #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Pcu object #388
Changes from 13 commits
Commits
Show all changes
120 commits
Select commit
Hold shift + click to select a range
feafdec
Add state to PCU mpi interface.
jacobmerson 7c390ee
Compile on gcc+fix bug
jacobmerson a4bbbfb
remove virtual function table for pcu_mpi
jacobmerson baf9370
Put PCU state data into a structure
jacobmerson 4c243cb
Use consistent initialization functions for MPI.
jacobmerson d891d2b
Add PCU2 interface that takes the PCU state struct
jacobmerson de2f57d
add PCU2.h to install files
jacobmerson 6a46101
fix compiler warnings
jacobmerson ed28c05
constify mpi functions
jacobmerson 2eada4e
first pass of PCU with making use of a high level object
jacobmerson eed5a0c
remove unused functions
jacobmerson f0b3a28
Fix gcc compilation
jacobmerson 0e7362f
fix bug
jacobmerson 0e0c80e
remove unnecessary whitespace
jacobmerson 07ab364
bump version
jacobmerson 80c829d
Add state to PCU mpi interface.
jacobmerson 2f6238c
Compile on gcc+fix bug
jacobmerson a5be7ae
remove virtual function table for pcu_mpi
jacobmerson 064ea13
Put PCU state data into a structure
jacobmerson e727d54
Use consistent initialization functions for MPI.
jacobmerson 47bf6d5
Add PCU2 interface that takes the PCU state struct
jacobmerson ef021f6
add PCU2.h to install files
jacobmerson 270d44e
fix compiler warnings
jacobmerson 62bfb69
constify mpi functions
jacobmerson 173c7ec
first pass of PCU with making use of a high level object
jacobmerson 23c7cef
remove unused functions
jacobmerson 438a73e
Fix gcc compilation
jacobmerson 4fa6e37
fix bug
jacobmerson 716133e
remove unnecessary whitespace
jacobmerson 4d281e0
bump version
jacobmerson 625b02b
Merge pull request #1 from flagdanger/pcu-object
jacobmerson 412addc
added pcu_ as a variable of Mesh
flagdanger 63bf279
Added getPCU(), and beginning to change pcu functions
flagdanger b364118
Can access global_pcu and some editing of function calls in /apf
flagdanger 1010eb1
Changed functions in more files up to folder ma
flagdanger 041b6f0
More PCU changes
flagdanger 435172e
More fixing
flagdanger 3f40db9
ph and pumi changes
flagdanger b1e41ff
more cleaning
flagdanger a2cb48f
test folder fixes
flagdanger da4383d
More test folder fixes
flagdanger 3c7b447
fixed last of test folder and made PCU2 .h and .cc
flagdanger 2ec87e3
Re-checked apf and pcu2 fix
flagdanger 3101beb
re-checking up to ma
flagdanger ee1d7e4
ma folder redo
flagdanger f13132e
more fixes
flagdanger 33a6621
Making new versions of functions to handle PCUHandle
flagdanger 8c5633a
phCook changes, changed phInput openfile_read to take PCUHandle, and …
flagdanger eaeaa3d
Reverting phasta changes
flagdanger 244a6d5
mds folder changed to use PCU2
flagdanger 5206e77
Last mds fixes (apfMDS.cc still has some issues)
flagdanger 8e2cdb0
Getting rid of include PCU.h in spots I missed
flagdanger 221a982
All parma changes I can do (lots of files need some workaround)
flagdanger 344e3c4
small pcu change
flagdanger 5ee39e5
pcu_getglobal changes
flagdanger cb971df
apfCap fix
flagdanger 2bb8171
crv fixes
flagdanger 23bf889
dsp pcu fix
flagdanger 60e0b6f
gmi cap and sim pcu fixes
flagdanger 63af137
ma pcu fixes
flagdanger 98e9d71
changing apfMDS.cc back to original, still needs work
flagdanger 6f49fb2
pumi pcu fixes
flagdanger 14d2e5e
spr pcu fix
flagdanger 5f17c05
stk pcu fixes
flagdanger bc1ce6a
changing repartition.cc back to original, still needs work
flagdanger 59d5a7f
zoltan pcu fixes
flagdanger 98341a3
pumi interface fixes, replacing old PCU uses
flagdanger a0c53fc
files in test folder changed to use new pumi - pcu interface
flagdanger 32ab95b
made default PCU arguments for Mesh functions and fixed old pcu issue…
flagdanger 530a82e
repartition test file rebuilt to use new pcu
flagdanger fda3f51
apf folder using new pcu except apfNumbering.cc
flagdanger bdce405
ma folder changed to use new pcu, changed some uses of print() in crv…
flagdanger 9075f4b
ma folder using new pcu, all tests passing
flagdanger efc2d77
changed phastaio_initStats to not check if PCU is intitialized. Also …
flagdanger d424963
Phasta folder changed to use new PCU, passes tests.
flagdanger 9005de8
small touchups in test files, apfMDS.cc, and apf_sim
flagdanger 6bb2806
Parma folder fixes, only thing not changed is parma_group.cc, all tes…
flagdanger 6cbd11d
added switchPCU to apfMesh to use in parma_group.cc
flagdanger 000418e
parma_group.cc fixed to use switchPCU, may need to change later
flagdanger bd265d8
parallelReduce function fix
flagdanger 7f83066
crv corrected makeEmptyMdsMesh use
flagdanger 8469c37
ma corrected makeEmptyMdsMesh use
flagdanger 2b90da5
fixed BoxBuilder class and loadMdsFromANSYS to take an optional PCUObj
flagdanger 961f09a
got rid of undef PCU_FORMAT_ATTRIBUTE, fixed compilation errors that …
flagdanger daed911
phasta - fixed createMdsMesh use
flagdanger 946ba7c
got rid of an #include PCU.h
flagdanger 8c28b15
#include PCU.h deletion
flagdanger 7a99da1
spr folder fixes
flagdanger 99ad2db
1d test file
flagdanger 77cb68f
align test file
flagdanger 1dc3a94
aniso_ma_test file
flagdanger becd83a
ansys test file
flagdanger e591d9a
assert_timing test file
flagdanger dc48ea7
balance test file
flagdanger 4624408
bezierElevation test file
flagdanger 0a7ccec
box test file
flagdanger 54cc6be
collapse test file
flagdanger f6e5d7c
poisson test file
flagdanger 5f0ef7e
mdsCGNS PCUHandle fix
flagdanger 6452f43
maximal independent set fixes
flagdanger 8cb06bb
Parma_GroupCode run() function default changed to take a PCUObj
flagdanger f36021a
Test files fixed
flagdanger 0db8e21
loadMdsPart take optional PCU
flagdanger 6f4c6df
loadMdsFromGmsh to take PCU
flagdanger 9900b46
fixed runInGroups() to work with new PCU
flagdanger b0a6ff2
reverted the run function in GroupCode structs to not take a PCU
flagdanger 52c9ab8
test files fixed to use PCUObj; all pass
flagdanger 1eebc1e
Mesh interface fixes
flagdanger 94dcc92
Test files changed to use new PCU
flagdanger 7dbae41
Added comments for uses of switchPCU
flagdanger 2b03519
added back reeResidualFunctionals.cc
flagdanger 00bf25e
Delete config.sh
flagdanger 2f23fb1
Merge pull request #2 from flagdanger/pcu-object
jacobmerson 03eb93d
Merge branch 'develop' into pcu-object
jacobmerson ea3b36e
Warning fixes
flagdanger b2ae31a
Merge branch 'pcu-object' of https://github.com/flagdanger/core into …
flagdanger d95cdcd
Merge pull request #3 from flagdanger/pcu-object
jacobmerson 769c432
compiler errors with phLinks.cc fixed
flagdanger f96b764
.github fix
flagdanger 1e3d684
describe.cc getPeak() and getChunks() removed
flagdanger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ message(STATUS "PCU_COMPRESS: " ${PCU_COMPRESS}) | |
|
|
||
| # Package sources | ||
| set(SOURCES | ||
| pcu.c | ||
| pcu.cc | ||
| pcu_aa.c | ||
| pcu_coll.c | ||
| pcu_io.c | ||
|
|
@@ -22,14 +22,15 @@ set(SOURCES | |
| pcu_util.c | ||
| noto/noto_malloc.c | ||
| reel/reel.c | ||
| ) | ||
| PCUObj.cc) | ||
|
|
||
| # Package headers | ||
| set(HEADERS | ||
| PCU.h | ||
| pcu_io.h | ||
| pcu_io.h | ||
|
||
| pcu_util.h | ||
| reel/reel.h | ||
| pcu_defines.h | ||
| ) | ||
|
|
||
| # Add the pcu library | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,292 @@ | ||
| #include "PCUObj.h" | ||
| #include "noto_malloc.h" | ||
| #include "pcu_mem.h" | ||
| #include "pcu_mpi.h" | ||
| #include "pcu_msg.h" | ||
| #include "pcu_order.h" | ||
| #include "reel.h" | ||
| #include <algorithm> | ||
| #include <sys/stat.h> /*using POSIX mkdir call for SMB "foo/" path*/ | ||
| #include <climits> | ||
| #include <cstring> | ||
| #include <cerrno> | ||
| #include <cstdarg> | ||
| namespace pcu { | ||
|
|
||
| int PCU::Peers() const noexcept { return pcu_mpi_size(mpi_); } | ||
| int PCU::Self() const noexcept { return pcu_mpi_rank(mpi_); } | ||
| void PCU::Begin() noexcept { pcu_msg_start(mpi_, msg_); } | ||
| int PCU::Pack(int to_rank, const void *data, size_t size) noexcept { | ||
| if ((to_rank < 0) || (to_rank >= Peers())) | ||
| reel_fail("Invalid rank in Comm_Pack"); | ||
| if (size > (size_t)INT_MAX) { | ||
| fprintf(stderr, "ERROR Attempting to pack a PCU message whose size exceeds " | ||
| "INT_MAX... exiting\n"); | ||
| abort(); | ||
| } | ||
| memcpy(pcu_msg_pack(msg_, to_rank, size), data, size); | ||
| return PCU_SUCCESS; | ||
| } | ||
| int PCU::Send() noexcept { | ||
| pcu_msg_send(mpi_, msg_); | ||
| return PCU_SUCCESS; | ||
| } | ||
| bool PCU::Receive() noexcept { | ||
| while (Unpacked()) | ||
| if (!Listen()) | ||
| return false; | ||
| return true; | ||
| } | ||
| bool PCU::Listen() noexcept { | ||
| if (msg_->order) | ||
| return pcu_order_receive(mpi_, msg_->order, msg_); | ||
| return pcu_msg_receive(mpi_, msg_); | ||
| } | ||
| int PCU::Sender() noexcept { | ||
| if (msg_->order) | ||
| return pcu_order_received_from(msg_->order); | ||
| return pcu_msg_received_from(msg_); | ||
| } | ||
| bool PCU::Unpacked() noexcept { | ||
| if (msg_->order) | ||
| return pcu_order_unpacked(msg_->order); | ||
| return pcu_msg_unpacked(msg_); | ||
| } | ||
| int PCU::Unpack(void *data, size_t size) noexcept { | ||
| if (msg_->order) | ||
| memcpy(data, pcu_order_unpack(msg_->order, size), size); | ||
| else | ||
| memcpy(data, pcu_msg_unpack(msg_, size), size); | ||
| return PCU_SUCCESS; | ||
| } | ||
| int PCU::Write(int to_rank, const void *data, size_t size) noexcept { | ||
| if ((to_rank < 0) || (to_rank >= Peers())) | ||
| reel_fail("Invalid rank in Comm_Write"); | ||
| PCU_MSG_PACK(msg_, to_rank, size); | ||
| memcpy(pcu_msg_pack(msg_, to_rank, size), data, size); | ||
| return PCU_SUCCESS; | ||
| } | ||
| bool PCU::Read(int *from_rank, void **data, size_t *size) noexcept { | ||
| if (!Receive()) | ||
| return false; | ||
| *from_rank = Sender(); | ||
| Unpack(size, sizeof(*size)); | ||
| *data = Extract(*size); | ||
| return true; | ||
| } | ||
| void PCU::Order(bool on) { | ||
| if (on && (!msg_->order)) | ||
| msg_->order = pcu_order_new(); | ||
| if ((!on) && msg_->order) { | ||
| pcu_order_free(msg_->order); | ||
| msg_->order = NULL; | ||
| } | ||
| } | ||
| void PCU::Barrier() { pcu_barrier(mpi_, &(msg_->coll)); } | ||
| int PCU::Or(int c) noexcept { return Max(c); } | ||
| int PCU::And(int c) noexcept { return Min(c); } | ||
| int PCU::Packed(int to_rank, size_t *size) noexcept { | ||
| if ((to_rank < 0) || (to_rank >= Peers())) | ||
| reel_fail("Invalid rank in Comm_Packed"); | ||
| *size = pcu_msg_packed(msg_, to_rank); | ||
| return PCU_SUCCESS; | ||
| } | ||
| int PCU::From(int *from_rank) noexcept { | ||
| if (msg_->order) | ||
| *from_rank = pcu_order_received_from(msg_->order); | ||
| else | ||
| *from_rank = pcu_msg_received_from(msg_); | ||
| return PCU_SUCCESS; | ||
| } | ||
| int PCU::Received(size_t *size) noexcept { | ||
| if (msg_->order) | ||
| *size = pcu_order_received_size(msg_->order); | ||
| else | ||
| *size = pcu_msg_received_size(msg_); | ||
| return PCU_SUCCESS; | ||
| } | ||
| void *PCU::Extract(size_t size) noexcept { | ||
| if (msg_->order) | ||
| return pcu_order_unpack(msg_->order, size); | ||
| return pcu_msg_unpack(msg_, size); | ||
| } | ||
|
|
||
| static void safe_mkdir(const char *path, mode_t mode) { | ||
| int err; | ||
| errno = 0; | ||
| err = mkdir(path, mode); | ||
| if (err != 0 && errno != EEXIST) | ||
| reel_fail("PCU: could not create directory \"%s\"\n", path); | ||
| } | ||
|
|
||
| static void append(char *s, size_t size, const char *format, ...) { | ||
| int len = strlen(s); | ||
| va_list ap; | ||
| va_start(ap, format); | ||
| vsnprintf(s + len, size - len, format, ap); | ||
| va_end(ap); | ||
| } | ||
|
|
||
| void PCU::DebugOpen() noexcept { | ||
| const int fanout = 2048; | ||
| const int bufsize = 1024; | ||
| char *path = (char *)noto_malloc(bufsize); | ||
| path[0] = '\0'; | ||
| if (Peers() > fanout) { | ||
| mode_t const dir_perm = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | ||
| strcpy(path, "debug/"); | ||
| safe_mkdir(path, dir_perm); | ||
| int self = Self(); | ||
| append(path, bufsize, "%d/", self / fanout); | ||
| if (self % fanout == 0) | ||
| safe_mkdir(path, dir_perm); | ||
| Barrier(); | ||
| } | ||
|
|
||
| append(path, bufsize, "%s", "debug"); | ||
| if (!msg_->file) | ||
| msg_->file = pcu_open_parallel(path, "txt"); | ||
| noto_free(path); | ||
| } | ||
|
|
||
| double GetMem() noexcept { return pcu_get_mem(); } | ||
| void Protect() noexcept { reel_protect(); } | ||
| double Time() noexcept { return MPI_Wtime(); } | ||
|
|
||
| void PCU::DebugPrint(const char *format, ...) noexcept { | ||
| va_list args; | ||
| va_start(args, format); | ||
| DebugPrint(format, args); | ||
| va_end(args); | ||
| } | ||
| void PCU::DebugPrint(const char *format, va_list args) noexcept { | ||
| if (!msg_->file) | ||
| return; // Print is a no-op if no file is open | ||
| vfprintf(msg_->file, format, args); | ||
| fflush(msg_->file); | ||
| } | ||
| PCU::PCU(MPI_Comm comm) { | ||
| mpi_ = new pcu_mpi_t; | ||
| msg_ = new pcu_msg; | ||
| pcu_mpi_init(comm, mpi_); | ||
| pcu_make_msg(msg_); | ||
| /* turn ordering on by default, call | ||
| PCU_Comm_Order(false) after PCU_Comm_Init | ||
| to disable this */ | ||
| Order(true); | ||
| } | ||
| PCU::~PCU() noexcept { | ||
| pcu_mpi_finalize(mpi_); | ||
| delete mpi_; | ||
| pcu_free_msg(msg_); | ||
| delete msg_; | ||
| } | ||
| PCU::PCU(PCU &&other) noexcept { | ||
| std::swap(mpi_, other.mpi_); | ||
| std::swap(msg_, other.msg_); | ||
| } | ||
| PCU &PCU::operator=(PCU && other) noexcept { | ||
| std::swap(mpi_, other.mpi_); | ||
| std::swap(msg_, other.msg_); | ||
| return *this; | ||
| } | ||
| MPI_Comm PCU::GetMPIComm() const noexcept { return mpi_->original_comm; } | ||
|
|
||
| MPI_Comm PCU::SwitchMPIComm(MPI_Comm newcomm) noexcept { | ||
| if(newcomm == mpi_->original_comm) { | ||
| return mpi_->original_comm; | ||
| } | ||
| auto original_comm = mpi_->original_comm; | ||
| pcu_mpi_finalize(mpi_); | ||
| pcu_mpi_init(newcomm, mpi_); | ||
| return original_comm; | ||
| } | ||
|
|
||
| /* template implementations */ | ||
| template <typename T> void PCU::Add(T *p, size_t n) noexcept { | ||
| pcu_allreduce( | ||
| mpi_, &(msg_->coll), | ||
| [](void *local, void *incoming, size_t size) { | ||
| auto *a = static_cast<T *>(local); | ||
| auto *b = static_cast<T *>(incoming); | ||
| size_t n = size / sizeof(T); | ||
| for (size_t i = 0; i < n; ++i) | ||
| a[i] += b[i]; | ||
| }, | ||
| p, n * sizeof(T)); | ||
| } | ||
| template <typename T> T PCU::Add(T p) noexcept { | ||
| Add(&p, 1); | ||
| return p; | ||
| } | ||
| template <typename T> void PCU::Min(T *p, size_t n) noexcept { | ||
| pcu_allreduce( | ||
| mpi_, &(msg_->coll), | ||
| [](void *local, void *incoming, size_t size) { | ||
| auto *a = static_cast<T *>(local); | ||
| auto *b = static_cast<T *>(incoming); | ||
| size_t n = size / sizeof(T); | ||
| for (size_t i = 0; i < n; ++i) | ||
| a[i] = std::min(a[i], b[i]); | ||
| }, | ||
| p, n * sizeof(T)); | ||
| } | ||
| template <typename T> T PCU::Min(T p) noexcept { | ||
| Min(&p, 1); | ||
| return p; | ||
| } | ||
| template <typename T> void PCU::Max(T *p, size_t n) noexcept { | ||
| pcu_allreduce( | ||
| mpi_, &(msg_->coll), | ||
| [](void *local, void *incoming, size_t size) { | ||
| auto *a = static_cast<T *>(local); | ||
| auto *b = static_cast<T *>(incoming); | ||
| size_t n = size / sizeof(T); | ||
| for (size_t i = 0; i < n; ++i) | ||
| a[i] = std::max(a[i], b[i]); | ||
| }, | ||
| p, n * sizeof(T)); | ||
| } | ||
| template <typename T> T PCU::Max(T p) noexcept { | ||
| Max(&p, 1); | ||
| return p; | ||
| } | ||
| template <typename T> void PCU::Exscan(T *p, size_t n) noexcept { | ||
| auto *originals = (T *)noto_malloc(sizeof(T) * n); | ||
| for (size_t i = 0; i < n; ++i) | ||
| originals[i] = p[i]; | ||
| pcu_scan( | ||
| mpi_, &(msg_->coll), | ||
| [](void *local, void *incoming, size_t size) { | ||
| auto *a = static_cast<T *>(local); | ||
| auto *b = static_cast<T *>(incoming); | ||
| size_t n = size / sizeof(T); | ||
| for (size_t i = 0; i < n; ++i) | ||
| a[i] += b[i]; | ||
| }, | ||
| p, n * sizeof(T)); | ||
| // convert inclusive scan to exclusive | ||
| for (size_t i = 0; i < n; ++i) | ||
| p[i] -= originals[i]; | ||
| noto_free(originals); | ||
| } | ||
| template <typename T> T PCU::Exscan(T p) noexcept { | ||
| Exscan(&p, 1); | ||
| return p; | ||
| } | ||
| #define PCU_EXPL_INST_DECL(T) \ | ||
| template void PCU::Add<T>(T * p, size_t n) noexcept; \ | ||
| template T PCU::Add<T>(T p) noexcept; \ | ||
| template void PCU::Min<T>(T * p, size_t n) noexcept; \ | ||
| template T PCU::Min<T>(T p) noexcept; \ | ||
| template void PCU::Max<T>(T * p, size_t n) noexcept; \ | ||
| template T PCU::Max<T>(T p) noexcept; \ | ||
| template void PCU::Exscan<T>(T * p, size_t n) noexcept; \ | ||
| template T PCU::Exscan<T>(T p) noexcept; | ||
| PCU_EXPL_INST_DECL(int) | ||
| PCU_EXPL_INST_DECL(size_t) | ||
| PCU_EXPL_INST_DECL(long) | ||
| PCU_EXPL_INST_DECL(double) | ||
| #undef PCU_EXPL_INST_DECL | ||
|
|
||
| } // namespace pcu |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra whitespace?