aboutsummaryrefslogtreecommitdiff
path: root/src/Panda/App_Info.C
diff options
context:
space:
mode:
Diffstat (limited to 'src/Panda/App_Info.C')
-rw-r--r--src/Panda/App_Info.C96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/Panda/App_Info.C b/src/Panda/App_Info.C
new file mode 100644
index 0000000..77f1d4b
--- /dev/null
+++ b/src/Panda/App_Info.C
@@ -0,0 +1,96 @@
+#include "definitions.h"
+#include "App_Info.h"
+
+App_Info::App_Info(int app_num, int app_size, int *world_ranks)
+{
+ int world_size;
+
+ app_num_ = app_num;
+ app_size_ = app_size;
+ world_ranks_ = copy_int_list(app_size, world_ranks);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
+ relative_ranks_ = (int *) malloc(sizeof(int)*world_size);
+ for(int i=0; i < world_size; i++)
+ relative_ranks_[i] = -1;
+ for(i=0; i < app_size_; i++)
+ relative_ranks_[world_ranks_[i]] = i;
+ intra_comm_ = NULL;
+ combine_count_ = 0;
+
+#ifdef DEBUG
+ printf("Creating an new App Info object\n");
+ printf("App_num = %d App_size = %d\n", app_num_, app_size_);
+ printf("Ranks relative: world: world-relative\n");
+ for(int j=0;j<app_size_;j++)
+ printf(" %d %d %d\n", j, world_ranks_[j],
+ relative_ranks_[world_ranks_[j]]);
+#endif
+}
+
+
+App_Info::~App_Info()
+{
+ if (world_ranks_ != NULL) free(world_ranks_);
+ if (relative_ranks_ != NULL) free(relative_ranks_);
+ if (intra_comm_ != NULL)
+ {
+ MPI_Comm_free(intra_comm_);
+ free(intra_comm_);
+ intra_comm_ =NULL;
+ }
+ world_ranks_ = NULL;
+ relative_ranks_ = NULL;
+}
+
+
+int App_Info::app_num(){ return app_num_;}
+
+int App_Info::app_size(){ return app_size_;}
+
+int App_Info::get_master(){ return world_ranks_[0];}
+
+int App_Info::world_rank(int relative_rank)
+{
+ return world_ranks_[relative_rank];
+}
+
+int App_Info::relative_rank(int world_rank)
+{
+ return relative_ranks_[world_rank];
+}
+
+void App_Info::set_intra_comm(MPI_Comm *intra_comm)
+{
+ intra_comm_ = intra_comm;
+}
+
+MPI_Comm* App_Info::intra_comm()
+{
+ return intra_comm_;
+}
+
+void App_Info::inc_combine_count()
+{
+ combine_count_++;
+}
+
+int App_Info::combine_count()
+{
+ return combine_count_;
+}
+
+void App_Info::reset_combine_count()
+{
+ combine_count_ = 0;
+}
+
+
+int* App_Info::world_ranks(){
+ return world_ranks_;
+}
+
+void App_Info::world_ranks(int *ret_list)
+{
+ for(int i=0; i < app_size_; i++)
+ ret_list[i] = world_ranks_[i];
+}