├── mpi_t ├── varlist │ ├── README │ ├── CMakeLists.txt │ ├── LICENSE.txt │ ├── FULL-LICENSE.txt │ └── varlist.c └── gyan │ ├── Makefile │ ├── README │ ├── LICENSE.txt │ ├── utility.h │ ├── tests │ ├── osu_bcast.c │ ├── osu_coll.h │ └── osu_bw.c │ ├── utility.c │ ├── gyan.c │ └── FULL-LICENSE.txt └── README /mpi_t/varlist/README: -------------------------------------------------------------------------------- 1 | To compile: 2 | mkdir dir 3 | cd dir 4 | cmake .. 5 | 6 | To run: 7 | ./varlist 8 | -------------------------------------------------------------------------------- /mpi_t/varlist/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | ##Add targets 3 | #C 4 | find_package(MPI) 5 | add_executable(varlist varlist.c) 6 | 7 | target_link_libraries(varlist ${MPI_C_LIBRARIES}) 8 | 9 | include_directories( 10 | ${MPI_C_INCLUDE_PATH} 11 | ${MPI_Fortran_INCLUDE_PATH}) 12 | 13 | -------------------------------------------------------------------------------- /mpi_t/gyan/Makefile: -------------------------------------------------------------------------------- 1 | CC=mpicc 2 | BIN_CFLAGS=-g -O0 -Wall 3 | CFLAGS=$(BIN_CFLAGS) -fPIC 4 | LIBPATH=-L. 5 | INCLUDE= 6 | LIBS=-lgyan 7 | EXE=tool.o 8 | TESTDIR=tests 9 | 10 | all: 11 | $(CC) $(CFLAGS) -c utility.c -o utility.o 12 | $(CC) $(CFLAGS) -c gyan.c -o gyan.o 13 | ar rcs libgyan.a gyan.o 14 | $(CC) -shared -o libgyan.so utility.o gyan.o 15 | $(CC) $(CFLAGS) $(INCLUDE) $(TESTDIR)/osu_bw.c $(LIBPATH) -o $(TESTDIR)/osu_bw $(LIBS) 16 | $(CC) $(CFLAGS) $(INCLUDE) $(TESTDIR)/osu_bcast.c $(LIBPATH) -o $(TESTDIR)/osu_bcast $(LIBS) 17 | clean: 18 | rm -f *.o 19 | rm -f $(TESTDIR)/osu_bw $(TESTDIR)/osu_bcast 20 | rm -f libgyan.so libgyan.a 21 | -------------------------------------------------------------------------------- /mpi_t/gyan/README: -------------------------------------------------------------------------------- 1 | Build Instructions 2 | ------------------ 3 | - Set MPI_INSTALL in Makefile to point to an MPI-T compliant MPI 4 | installation 5 | - Run "make" 6 | 7 | 8 | Usage Instructions 9 | ------------------ 10 | 11 | - Gyan can be used in one of two ways: 12 | - By dynamically loading the libgyan shared-library. 13 | $ LD_PRELOAD=$GYAN_INSTALL_PATH/libgyan.so srun -n 2 mpi_app 14 | - By statically linking the MPI application to libgyan. 15 | $ srun -n 2 mpi_app 16 | 17 | - The sample MPI benchmarks in "tests" folder have been statically linked to 18 | libgyan, and can be used to test the installation. Run them as follows: 19 | $ srun -n 2 ./tests/osu_bcast 20 | -------------------------------------------------------------------------------- /mpi_t/varlist/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Lawrence Livermore National Security, 2 | LLC. Produced at the Lawrence Livermore National Laboratory. Written 3 | by Martin Schulz (schulzm@llnl.gov). CODE-LLNL-CODE-647221. All rights 4 | reserved. This file is part of mpi_T-tools. For details, see 5 | https://computation-rnd.llnl.gov/mpi_t/varList.php. Please also read 6 | this file - ./FULL-LICENSE.txt. 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License (as published by 9 | the Free Software Foundation) version 2.1 dated February 1999. 10 | This program is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and 13 | conditions of the GNU General Public License for more details. You 14 | should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 17 | USA 18 | -------------------------------------------------------------------------------- /mpi_t/gyan/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Lawrence Livermore National Security, 2 | LLC. Produced at the Lawrence Livermore National Laboratory. Written 3 | by Tanzima Z. Islam (islam3@llnl.gov). 4 | CODE-LLNL-CODE-647221. All rights reserved. 5 | This file is part of mpi_T-tools. For details, see 6 | https://computation-rnd.llnl.gov/mpi_t/gyan.php. 7 | Please also read this file - FULL-LICENSE.txt. 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License (as published by 10 | the Free Software Foundation) version 2.1 dated February 1999. 11 | This program is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 14 | and conditions of the GNU General Public License for more 15 | details. You should have received a copy of the GNU Lesser General 16 | Public License along with this program; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | MPI_T is an interface for tools introduced in the 3.0 version of MPI. 3 | The interface provides mechanisms for tools to access and set 4 | performance and control variables that are exposed by an MPI 5 | implementation. For example, a tool may be able to record the length 6 | of the unexpected message queue over the course of the execution; or a 7 | tool could set the value of the "eager limit" for better message 8 | passing performance. The number and types of variables that are 9 | exposed is completely determined by the MPI implementation and need to 10 | be discovered by tools via the query interface. Thus, tool writers 11 | need to take care to code in such a way that they are not dependent on 12 | a single implementation's variables. Major implementations, including 13 | Open MPI , MPICH and MVAPICH, are working to support this interface, 14 | so the functionality will be available to tools in the near future. 15 | 16 | We have developed a set of simple MPI_T tools to get tool writers 17 | started on the path to more sophisticated support of the new interface 18 | and make them available here. The tools are Gyan and VarList. 19 | 20 | -------------------------------------------------------------------------------- /mpi_t/gyan/utility.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014, Lawrence Livermore National Security, 3 | // LLC. Produced at the Lawrence Livermore National Laboratory. Written 4 | // by Tanzima Z. Islam (islam3@llnl.gov). 5 | // CODE-LLNL-CODE-647221. All rights reserved. 6 | // This file is part of mpi_T-tools. For details, see 7 | // https://computation-rnd.llnl.gov/mpi_t/gyan.php. 8 | // Please also read this file - FULL-LICENSE.txt. 9 | // This program is free software; you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License (as published by 11 | // the Free Software Foundation) version 2.1 dated February 1999. 12 | // This program is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 15 | // and conditions of the GNU General Public License for more 16 | // details. You should have received a copy of the GNU Lesser General 17 | // Public License along with this program; if not, write to the Free 18 | // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | // 02111-1307 USA 20 | ////////////////////////////////////////////////////////////////////////////// 21 | /* 22 | * utility.h 23 | * 24 | * Created on: Oct 22, 2013 25 | * Author: islam3 26 | */ 27 | #include /* Adds MPI_T definiKons as well */ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #ifndef UTILITY_H_ 35 | #define UTILITY_H_ 36 | 37 | char* get_pvars_name_list(); 38 | char* get_pvar_class(int c); 39 | void print_filled(char *s, int len, char c); 40 | void print_variable( 41 | MPI_T_pvar_session sess, 42 | MPI_T_pvar_handle handle2, 43 | char *name, 44 | MPI_Datatype datatype, 45 | int count, 46 | unsigned long long int **value_buffer); 47 | void print_class(int c); 48 | #endif /* UTILITY_H_ */ 49 | -------------------------------------------------------------------------------- /mpi_t/gyan/tests/osu_bcast.c: -------------------------------------------------------------------------------- 1 | #define BENCHMARK "OSU MPI%s Broadcast Latency Test" 2 | /* 3 | * Copyright (C) 2002-2013 the Network-Based Computing Laboratory 4 | * (NBCL), The Ohio State University. 5 | * 6 | * Contact: Dr. D. K. Panda (panda@cse.ohio-state.edu) 7 | * 8 | * For detailed copyright and licensing information, please refer to the 9 | * copyright file COPYRIGHT in the top level OMB directory. 10 | */ 11 | 12 | #include "osu_coll.h" 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | int i = 0, rank, size; 17 | int skip, numprocs; 18 | double avg_time = 0.0, max_time = 0.0, min_time = 0.0; 19 | double latency = 0.0, t_start = 0.0, t_stop = 0.0; 20 | double timer=0.0; 21 | char *buffer=NULL; 22 | int max_msg_size = 1048576, full = 0; 23 | 24 | MPI_Init(&argc, &argv); 25 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 26 | MPI_Comm_size(MPI_COMM_WORLD, &numprocs); 27 | 28 | if (process_args(argc, argv, rank, &max_msg_size, &full)) { 29 | MPI_Finalize(); 30 | return EXIT_SUCCESS; 31 | } 32 | 33 | if(numprocs < 2) { 34 | if(rank == 0) { 35 | fprintf(stderr, "This test requires at least two processes\n"); 36 | } 37 | 38 | MPI_Finalize(); 39 | 40 | return EXIT_FAILURE; 41 | } 42 | 43 | print_header(rank, full); 44 | 45 | buffer = malloc(max_msg_size * sizeof(char)); 46 | if(NULL == buffer) { 47 | fprintf(stderr, "malloc failed.\n"); 48 | exit(1); 49 | } 50 | 51 | memset(buffer,1, max_msg_size); 52 | 53 | for(size=1; size <=max_msg_size; size *= 2) { 54 | if(size > LARGE_MESSAGE_SIZE) { 55 | skip = SKIP_LARGE; 56 | iterations = iterations_large; 57 | } 58 | else { 59 | skip = SKIP; 60 | } 61 | 62 | timer=0.0; 63 | for(i=0; i < iterations + skip ; i++) { 64 | t_start = MPI_Wtime(); 65 | MPI_Bcast(buffer, size, MPI_CHAR, 0, MPI_COMM_WORLD); 66 | t_stop = MPI_Wtime(); 67 | 68 | if(i>=skip){ 69 | timer+=t_stop-t_start; 70 | } 71 | MPI_Barrier(MPI_COMM_WORLD); 72 | 73 | } 74 | 75 | MPI_Barrier(MPI_COMM_WORLD); 76 | 77 | latency = (timer * 1e6) / iterations; 78 | 79 | MPI_Reduce(&latency, &min_time, 1, MPI_DOUBLE, MPI_MIN, 0, 80 | MPI_COMM_WORLD); 81 | MPI_Reduce(&latency, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, 82 | MPI_COMM_WORLD); 83 | MPI_Reduce(&latency, &avg_time, 1, MPI_DOUBLE, MPI_SUM, 0, 84 | MPI_COMM_WORLD); 85 | avg_time = avg_time/numprocs; 86 | 87 | print_data(rank, full, size, avg_time, min_time, max_time, iterations); 88 | } 89 | 90 | free(buffer); 91 | MPI_Finalize(); 92 | 93 | return EXIT_SUCCESS; 94 | } 95 | 96 | /* vi: set sw=4 sts=4 tw=80: */ 97 | -------------------------------------------------------------------------------- /mpi_t/gyan/utility.c: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014, Lawrence Livermore National Security, 3 | // LLC. Produced at the Lawrence Livermore National Laboratory. Written 4 | // by Tanzima Z. Islam (islam3@llnl.gov). 5 | // CODE-LLNL-CODE-647221. All rights reserved. 6 | // This file is part of mpi_T-tools. For details, see 7 | // https://computation-rnd.llnl.gov/mpi_t/gyan.php. 8 | // Please also read this file - FULL-LICENSE.txt. 9 | // This program is free software; you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License (as published by 11 | // the Free Software Foundation) version 2.1 dated February 1999. 12 | // This program is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 15 | // and conditions of the GNU General Public License for more 16 | // details. You should have received a copy of the GNU Lesser General 17 | // Public License along with this program; if not, write to the Free 18 | // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | // 02111-1307 USA 20 | ////////////////////////////////////////////////////////////////////////////// 21 | /* 22 | * utility.c 23 | * 24 | * Created on: Oct 22, 2013 25 | * Author: islam3 26 | */ 27 | 28 | #include "utility.h" 29 | 30 | 31 | #define SCREENLEN 78 32 | 33 | #ifndef MPI_COUNT 34 | #define MPI_COUNT MPI_INT 35 | typedef int MPI_Count; 36 | #endif 37 | 38 | #ifndef MPI_T_CVAR_HANDLE_NULL 39 | #define MPI_T_CVAR_HANDLE_NULL NULL 40 | #endif 41 | 42 | #define CHECKERR(errstr,err) if (err!=MPI_SUCCESS) { printf("ERROR: %s: MPI error code %i\n",errstr,err); } 43 | 44 | 45 | char* get_pvars_name_list() 46 | { 47 | int num, i; 48 | char *name; 49 | char *class_name; 50 | int bind,vc,verbos,ro,ct,at; 51 | MPI_Datatype dt; 52 | MPI_T_enum et; 53 | int namelen, desclen; 54 | int total_length_of_pvar_names; 55 | char fname[105]; 56 | char fdesc[105]; 57 | int index; 58 | /* Get number of variables */ 59 | 60 | MPI_T_pvar_get_num(&num); 61 | 62 | /* Find string sizes */ 63 | total_length_of_pvar_names = 0; 64 | for (i = 0; i UNKNOWN DATATYPE: %s\n", name); 230 | } 231 | if(readbuf != NULL) 232 | free(readbuf); 233 | } 234 | 235 | 236 | -------------------------------------------------------------------------------- /mpi_t/gyan/tests/osu_coll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2013 the Network-Based Computing Laboratory 3 | * (NBCL), The Ohio State University. 4 | * 5 | * Contact: Dr. D. K. Panda (panda@cse.ohio-state.edu) 6 | * 7 | * For detailed copyright and licensing information, please refer to the 8 | * copyright file COPYRIGHT in the top level OMB directory. 9 | */ 10 | #ifndef OSU_COLL_H 11 | #define OSU_COLL_H 1 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #ifndef DEFAULT_MAX_MESSAGE_SIZE 22 | #define DEFAULT_MAX_MESSAGE_SIZE (1 << 20) 23 | #endif 24 | 25 | #define SKIP 200 26 | #define SKIP_LARGE 10 27 | #define LARGE_MESSAGE_SIZE 8192 28 | #define MAX_ALIGNMENT 16384 29 | #define MAX_MEM_LIMIT (512*1024*1024) 30 | #define MAX_MEM_LOWER_LIMIT (1*1024*1024) 31 | 32 | #ifdef _ENABLE_OPENACC_ 33 | # define OPENACC_ENABLED 1 34 | #else 35 | # define OPENACC_ENABLED 0 36 | #endif 37 | 38 | #ifdef _ENABLE_CUDA_ 39 | # define CUDA_ENABLED 1 40 | #else 41 | # define CUDA_ENABLED 0 42 | #endif 43 | 44 | #ifndef BENCHMARK 45 | # define BENCHMARK "MPI%s BENCHMARK NAME UNSET" 46 | #endif 47 | 48 | #ifdef PACKAGE_VERSION 49 | # define HEADER "# " BENCHMARK " v" PACKAGE_VERSION "\n" 50 | #else 51 | # define HEADER "# " BENCHMARK "\n" 52 | #endif 53 | 54 | #ifndef FIELD_WIDTH 55 | # define FIELD_WIDTH 20 56 | #endif 57 | 58 | #ifndef FLOAT_PRECISION 59 | # define FLOAT_PRECISION 2 60 | #endif 61 | 62 | static int iterations = 1000; 63 | static int iterations_large = 100; 64 | static int print_size = 0; 65 | static uint64_t max_mem_limit = MAX_MEM_LIMIT; 66 | static int process_args (int argc, char *argv[], int rank, int * size, int * full) __attribute__((unused)); 67 | static void print_header (int rank, int full) __attribute__((unused)); 68 | static void print_data (int rank, int full, int size, double avg_time, double 69 | min_time, double max_time, int iterations) __attribute__((unused)); 70 | 71 | static void print_usage(int rank, const char * prog, int has_size) 72 | { 73 | if (rank == 0) { 74 | if (has_size) { 75 | fprintf(stdout, " USAGE : %s [-m SIZE] [-i ITER] [-f] [-hv] [-M SIZE]\n", prog); 76 | fprintf(stdout, " -m : Set maximum message size to SIZE.\n"); 77 | fprintf(stdout, " By default, the value of SIZE is 1MB.\n"); 78 | fprintf(stdout, " -i : Set number of iterations per message size to ITER.\n"); 79 | fprintf(stdout, " By default, the value of ITER is 1000 for small messages\n"); 80 | fprintf(stdout, " and 100 for large messages.\n"); 81 | fprintf(stdout, " -M : Set maximum memory consumption (per process) to SIZE. \n"); 82 | fprintf(stdout, " By default, the value of SIZE is 512MB.\n"); 83 | } 84 | 85 | else { 86 | fprintf(stdout, " USAGE : %s [-i ITER] [-f] [-hv] \n", prog); 87 | fprintf(stdout, " -i : Set number of iterations to ITER.\n"); 88 | fprintf(stdout, " By default, the value of ITER is 1000.\n"); 89 | } 90 | 91 | fprintf(stdout, " -f : Print full format listing. With this option\n"); 92 | fprintf(stdout, " the MIN/MAX latency and number of ITERATIONS are\n"); 93 | fprintf(stdout, " printed out in addition to the AVERAGE latency.\n"); 94 | 95 | fprintf(stdout, " -h : Print this help.\n"); 96 | fprintf(stdout, " -v : Print version info.\n"); 97 | fprintf(stdout, "\n"); 98 | fflush(stdout); 99 | } 100 | } 101 | 102 | static void print_version() 103 | { 104 | fprintf(stdout, HEADER, ""); 105 | fflush(stdout); 106 | } 107 | 108 | static int process_args (int argc, char *argv[], int rank, int * size, int * full) 109 | { 110 | char c; 111 | 112 | if (size) { 113 | print_size = 1; 114 | } 115 | 116 | while ((c = getopt(argc, argv, ":hvfm:i:M:")) != -1) { 117 | switch (c) { 118 | case 'h': 119 | print_usage(rank, argv[0], size != NULL); 120 | return 1; 121 | 122 | case 'v': 123 | if (rank == 0) { 124 | print_version(); 125 | } 126 | 127 | return 1; 128 | 129 | case 'm': 130 | if (size) { 131 | *size = atoi(optarg); 132 | if (*size < 0) { 133 | print_usage(rank, argv[0], size != NULL); 134 | return -1; 135 | } 136 | } 137 | 138 | else { 139 | print_usage(rank, argv[0], 0); 140 | return -1; 141 | } 142 | break; 143 | 144 | case 'i': 145 | iterations_large = atoi(optarg); 146 | iterations = iterations_large; 147 | if (iterations < 1) { 148 | print_usage(rank, argv[0], size != NULL); 149 | return -1; 150 | } 151 | break; 152 | 153 | case 'f': 154 | *full = 1; 155 | break; 156 | 157 | case 'M': 158 | max_mem_limit = atoll(optarg); 159 | if (max_mem_limit < MAX_MEM_LOWER_LIMIT) { 160 | max_mem_limit = MAX_MEM_LOWER_LIMIT; 161 | if(rank == 0) fprintf(stderr,"Requested memory limit too low. "); 162 | if(rank == 0) fprintf(stderr,"Reverting to default lower-limit value %d\n", 163 | MAX_MEM_LOWER_LIMIT); 164 | } 165 | break; 166 | 167 | default: 168 | if (rank == 0) { 169 | print_usage(rank, argv[0], size != NULL); 170 | } 171 | 172 | return -1; 173 | } 174 | } 175 | 176 | return 0; 177 | } 178 | 179 | static void print_header (int rank, int full) 180 | { 181 | if(rank == 0) { 182 | fprintf(stdout, HEADER, ""); 183 | 184 | if (print_size) { 185 | fprintf(stdout, "%-*s", 10, "# Size"); 186 | fprintf(stdout, "%*s", FIELD_WIDTH, "Avg Latency(us)"); 187 | } 188 | 189 | else { 190 | fprintf(stdout, "# Avg Latency(us)"); 191 | } 192 | 193 | if (full) { 194 | fprintf(stdout, "%*s", FIELD_WIDTH, "Min Latency(us)"); 195 | fprintf(stdout, "%*s", FIELD_WIDTH, "Max Latency(us)"); 196 | fprintf(stdout, "%*s\n", 12, "Iterations"); 197 | } 198 | 199 | else { 200 | fprintf(stdout, "\n"); 201 | } 202 | 203 | fflush(stdout); 204 | } 205 | } 206 | 207 | static void print_data (int rank, int full, int size, double avg_time, double 208 | min_time, double max_time, int iterations) 209 | { 210 | if(rank == 0) { 211 | if (print_size) { 212 | fprintf(stdout, "%-*d", 10, size); 213 | fprintf(stdout, "%*.*f", FIELD_WIDTH, FLOAT_PRECISION, avg_time); 214 | } 215 | 216 | else { 217 | fprintf(stdout, "%*.*f", 17, FLOAT_PRECISION, avg_time); 218 | } 219 | 220 | if (full) { 221 | fprintf(stdout, "%*.*f%*.*f%*d\n", 222 | FIELD_WIDTH, FLOAT_PRECISION, min_time, 223 | FIELD_WIDTH, FLOAT_PRECISION, max_time, 224 | 12, iterations); 225 | } 226 | 227 | else { 228 | fprintf(stdout, "\n"); 229 | } 230 | 231 | fflush(stdout); 232 | } 233 | } 234 | 235 | enum po_ret_type { 236 | po_cuda_not_avail, 237 | po_openacc_not_avail, 238 | po_bad_usage, 239 | po_help_message, 240 | po_version_message, 241 | po_okay, 242 | }; 243 | 244 | enum accel_type { 245 | none, 246 | cuda, 247 | openacc 248 | }; 249 | 250 | struct { 251 | enum accel_type accel; 252 | int show_size; 253 | int show_full; 254 | size_t max_message_size; 255 | size_t iterations; 256 | size_t iterations_large; 257 | size_t max_mem_limit; 258 | } options; 259 | 260 | /* 261 | * Option Processing 262 | */ 263 | enum po_ret_type process_options (int argc, char *argv[]); 264 | 265 | /* 266 | * Print Information 267 | */ 268 | void print_bad_usage_message (int rank); 269 | void print_help_message (int rank); 270 | void print_version_message (int rank); 271 | void print_preamble (int rank); 272 | void print_stats (int rank, int size, double avg, double min, double max); 273 | 274 | /* 275 | * Memory Management 276 | */ 277 | int allocate_buffer (void ** buffer, size_t size, enum accel_type type); 278 | void free_buffer (void * buffer, enum accel_type type); 279 | void set_buffer (void * buffer, enum accel_type type, int data, size_t size); 280 | 281 | /* 282 | * CUDA Context Management 283 | */ 284 | int init_cuda_context (void); 285 | int destroy_cuda_context (void); 286 | 287 | /* 288 | * Set Benchmark Properties 289 | */ 290 | void set_header (const char * header); 291 | void set_benchmark_name (const char * name); 292 | void enable_accel_support (void); 293 | 294 | #endif 295 | -------------------------------------------------------------------------------- /mpi_t/gyan/tests/osu_bw.c: -------------------------------------------------------------------------------- 1 | #define BENCHMARK "OSU MPI%s Bandwidth Test" 2 | /* 3 | * Copyright (C) 2002-2013 the Network-Based Computing Laboratory 4 | * (NBCL), The Ohio State University. 5 | * 6 | * Contact: Dr. D. K. Panda (panda@cse.ohio-state.edu) 7 | * 8 | * For detailed copyright and licensing information, please refer to the 9 | * copyright file COPYRIGHT in the top level OMB directory. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef _ENABLE_OPENACC_ 21 | #include 22 | #endif 23 | 24 | #ifdef _ENABLE_CUDA_ 25 | #include 26 | #include 27 | #endif 28 | 29 | #ifdef PACKAGE_VERSION 30 | # define HEADER "# " BENCHMARK " v" PACKAGE_VERSION "\n" 31 | #else 32 | # define HEADER "# " BENCHMARK "\n" 33 | #endif 34 | 35 | #ifndef FIELD_WIDTH 36 | # define FIELD_WIDTH 20 37 | #endif 38 | 39 | #ifndef FLOAT_PRECISION 40 | # define FLOAT_PRECISION 2 41 | #endif 42 | 43 | #define MAX_REQ_NUM 1000 44 | 45 | #define MAX_ALIGNMENT 65536 46 | #define MAX_MSG_SIZE (1<<22) 47 | #define MYBUFSIZE (MAX_MSG_SIZE + MAX_ALIGNMENT) 48 | 49 | #define LOOP_LARGE 20 50 | #define WINDOW_SIZE_LARGE 64 51 | #define SKIP_LARGE 2 52 | #define LARGE_MESSAGE_SIZE 8192 53 | 54 | #ifdef _ENABLE_OPENACC_ 55 | # define OPENACC_ENABLED 1 56 | #else 57 | # define OPENACC_ENABLED 0 58 | #endif 59 | 60 | #ifdef _ENABLE_CUDA_ 61 | # define CUDA_ENABLED 1 62 | #else 63 | # define CUDA_ENABLED 0 64 | #endif 65 | 66 | char s_buf_original[MYBUFSIZE]; 67 | char r_buf_original[MYBUFSIZE]; 68 | 69 | MPI_Request request[MAX_REQ_NUM]; 70 | MPI_Status reqstat[MAX_REQ_NUM]; 71 | 72 | #ifdef _ENABLE_CUDA_ 73 | CUcontext cuContext; 74 | #endif 75 | 76 | enum po_ret_type { 77 | po_cuda_not_avail, 78 | po_openacc_not_avail, 79 | po_bad_usage, 80 | po_help_message, 81 | po_okay, 82 | }; 83 | 84 | enum accel_type { 85 | none, 86 | cuda, 87 | openacc 88 | }; 89 | 90 | struct { 91 | char src; 92 | char dst; 93 | enum accel_type accel; 94 | } options; 95 | 96 | void usage (void); 97 | int init_cuda_context (void); 98 | int destroy_cuda_context (void); 99 | int process_options (int argc, char *argv[]); 100 | int allocate_memory (char **sbuf, char **rbuf, int rank); 101 | void print_header (int rank); 102 | void touch_data (void *sbuf, void *rbuf, int rank, size_t size); 103 | void free_memory (void *sbuf, void *rbuf, int rank); 104 | 105 | int 106 | main (int argc, char *argv[]) 107 | { 108 | int myid, numprocs, i, j; 109 | int size; 110 | char *s_buf, *r_buf; 111 | double t_start = 0.0, t_end = 0.0, t = 0.0; 112 | int loop = 100; 113 | int window_size = 64; 114 | int skip = 10; 115 | int po_ret = process_options(argc, argv); 116 | 117 | if (po_okay == po_ret && cuda == options.accel) { 118 | if (init_cuda_context()) { 119 | fprintf(stderr, "Error initializing cuda context\n"); 120 | exit(EXIT_FAILURE); 121 | } 122 | } 123 | 124 | MPI_Init(&argc, &argv); 125 | MPI_Comm_size(MPI_COMM_WORLD, &numprocs); 126 | MPI_Comm_rank(MPI_COMM_WORLD, &myid); 127 | 128 | if (0 == myid) { 129 | switch (po_ret) { 130 | case po_cuda_not_avail: 131 | fprintf(stderr, "CUDA support not enabled. Please recompile " 132 | "benchmark with CUDA support.\n"); 133 | break; 134 | case po_openacc_not_avail: 135 | fprintf(stderr, "OPENACC support not enabled. Please " 136 | "recompile benchmark with OPENACC support.\n"); 137 | break; 138 | case po_bad_usage: 139 | case po_help_message: 140 | usage(); 141 | break; 142 | } 143 | } 144 | 145 | switch (po_ret) { 146 | case po_cuda_not_avail: 147 | case po_openacc_not_avail: 148 | case po_bad_usage: 149 | MPI_Finalize(); 150 | exit(EXIT_FAILURE); 151 | case po_help_message: 152 | MPI_Finalize(); 153 | exit(EXIT_SUCCESS); 154 | case po_okay: 155 | break; 156 | } 157 | 158 | if(numprocs != 2) { 159 | if(myid == 0) { 160 | fprintf(stderr, "This test requires exactly two processes\n"); 161 | } 162 | 163 | MPI_Finalize(); 164 | exit(EXIT_FAILURE); 165 | } 166 | 167 | if (allocate_memory(&s_buf, &r_buf, myid)) { 168 | /* Error allocating memory */ 169 | MPI_Finalize(); 170 | exit(EXIT_FAILURE); 171 | } 172 | 173 | print_header(myid); 174 | 175 | /* Bandwidth test */ 176 | for(size = 1; size <= MAX_MSG_SIZE; size *= 2) { 177 | touch_data(s_buf, r_buf, myid, size); 178 | 179 | if(size > LARGE_MESSAGE_SIZE) { 180 | loop = LOOP_LARGE; 181 | skip = SKIP_LARGE; 182 | window_size = WINDOW_SIZE_LARGE; 183 | } 184 | 185 | if(myid == 0) { 186 | for(i = 0; i < loop + skip; i++) { 187 | if(i == skip) { 188 | t_start = MPI_Wtime(); 189 | } 190 | 191 | for(j = 0; j < window_size; j++) { 192 | MPI_Isend(s_buf, size, MPI_CHAR, 1, 100, MPI_COMM_WORLD, 193 | request + j); 194 | } 195 | 196 | MPI_Waitall(window_size, request, reqstat); 197 | MPI_Recv(r_buf, 4, MPI_CHAR, 1, 101, MPI_COMM_WORLD, 198 | &reqstat[0]); 199 | } 200 | 201 | t_end = MPI_Wtime(); 202 | t = t_end - t_start; 203 | } 204 | 205 | else if(myid == 1) { 206 | for(i = 0; i < loop + skip; i++) { 207 | for(j = 0; j < window_size; j++) { 208 | MPI_Irecv(r_buf, size, MPI_CHAR, 0, 100, MPI_COMM_WORLD, 209 | request + j); 210 | } 211 | 212 | MPI_Waitall(window_size, request, reqstat); 213 | MPI_Send(s_buf, 4, MPI_CHAR, 0, 101, MPI_COMM_WORLD); 214 | } 215 | } 216 | 217 | if(myid == 0) { 218 | double tmp = size / 1e6 * loop * window_size; 219 | 220 | fprintf(stdout, "%-*d%*.*f\n", 10, size, FIELD_WIDTH, 221 | FLOAT_PRECISION, tmp / t); 222 | fflush(stdout); 223 | } 224 | } 225 | 226 | free_memory(s_buf, r_buf, myid); 227 | MPI_Finalize(); 228 | 229 | if (cuda == options.accel) { 230 | if (destroy_cuda_context()) { 231 | fprintf(stderr, "Error destroying cuda context\n"); 232 | exit(EXIT_FAILURE); 233 | } 234 | } 235 | 236 | return EXIT_SUCCESS; 237 | } 238 | 239 | void 240 | usage (void) 241 | { 242 | if (CUDA_ENABLED || OPENACC_ENABLED) { 243 | printf("Usage: osu_bw [options] [RANK0 RANK1]\n\n"); 244 | printf("RANK0 and RANK1 may be `D' or `H' which specifies whether\n" 245 | "the buffer is allocated on the accelerator device or host\n" 246 | "memory for each mpi rank\n\n"); 247 | } 248 | 249 | else { 250 | printf("Usage: osu_bw [options]\n\n"); 251 | } 252 | 253 | printf("options:\n"); 254 | 255 | if (CUDA_ENABLED || OPENACC_ENABLED) { 256 | printf(" -d TYPE accelerator device buffers can be of TYPE " 257 | "`cuda' or `openacc'\n"); 258 | } 259 | 260 | printf(" -h print this help message\n"); 261 | fflush(stdout); 262 | } 263 | 264 | int 265 | process_options (int argc, char *argv[]) 266 | { 267 | extern char * optarg; 268 | extern int optind; 269 | 270 | char const * optstring = (CUDA_ENABLED || OPENACC_ENABLED) ? "+d:h" : "+h"; 271 | int c; 272 | 273 | /* 274 | * set default options 275 | */ 276 | options.src = 'H'; 277 | options.dst = 'H'; 278 | 279 | if (CUDA_ENABLED) { 280 | options.accel = cuda; 281 | } 282 | 283 | else if (OPENACC_ENABLED) { 284 | options.accel = openacc; 285 | } 286 | 287 | else { 288 | options.accel = none; 289 | } 290 | 291 | while((c = getopt(argc, argv, optstring)) != -1) { 292 | switch (c) { 293 | case 'd': 294 | /* optarg should contain cuda or openacc */ 295 | if (0 == strncasecmp(optarg, "cuda", 10)) { 296 | if (!CUDA_ENABLED) { 297 | return po_cuda_not_avail; 298 | } 299 | options.accel = cuda; 300 | } 301 | 302 | else if (0 == strncasecmp(optarg, "openacc", 10)) { 303 | if (!OPENACC_ENABLED) { 304 | return po_openacc_not_avail; 305 | } 306 | options.accel = openacc; 307 | } 308 | 309 | else { 310 | return po_bad_usage; 311 | } 312 | break; 313 | case 'h': 314 | return po_help_message; 315 | default: 316 | return po_bad_usage; 317 | } 318 | } 319 | 320 | if (CUDA_ENABLED || OPENACC_ENABLED) { 321 | if ((optind + 2) == argc) { 322 | options.src = argv[optind][0]; 323 | options.dst = argv[optind + 1][0]; 324 | 325 | switch (options.src) { 326 | case 'D': 327 | case 'H': 328 | break; 329 | default: 330 | return po_bad_usage; 331 | } 332 | 333 | switch (options.dst) { 334 | case 'D': 335 | case 'H': 336 | break; 337 | default: 338 | return po_bad_usage; 339 | } 340 | } 341 | 342 | else if (optind != argc) { 343 | return po_bad_usage; 344 | } 345 | } 346 | 347 | return po_okay; 348 | } 349 | 350 | int 351 | init_cuda_context (void) 352 | { 353 | #ifdef _ENABLE_CUDA_ 354 | CUresult curesult = CUDA_SUCCESS; 355 | CUdevice cuDevice; 356 | int local_rank, dev_count; 357 | int dev_id = 0; 358 | char * str; 359 | 360 | if ((str = getenv("LOCAL_RANK")) != NULL) { 361 | cudaGetDeviceCount(&dev_count); 362 | local_rank = atoi(str); 363 | dev_id = local_rank % dev_count; 364 | } 365 | 366 | curesult = cuInit(0); 367 | if (curesult != CUDA_SUCCESS) { 368 | return 1; 369 | } 370 | 371 | curesult = cuDeviceGet(&cuDevice, dev_id); 372 | if (curesult != CUDA_SUCCESS) { 373 | return 1; 374 | } 375 | 376 | curesult = cuCtxCreate(&cuContext, 0, cuDevice); 377 | if (curesult != CUDA_SUCCESS) { 378 | return 1; 379 | } 380 | #endif 381 | return 0; 382 | } 383 | 384 | int 385 | allocate_device_buffer (char ** buffer) 386 | { 387 | #ifdef _ENABLE_CUDA_ 388 | cudaError_t cuerr = cudaSuccess; 389 | #endif 390 | 391 | switch (options.accel) { 392 | #ifdef _ENABLE_CUDA_ 393 | case cuda: 394 | cuerr = cudaMalloc((void **)buffer, MYBUFSIZE); 395 | 396 | if (cudaSuccess != cuerr) { 397 | fprintf(stderr, "Could not allocate device memory\n"); 398 | return 1; 399 | } 400 | break; 401 | #endif 402 | #ifdef _ENABLE_OPENACC_ 403 | case openacc: 404 | *buffer = acc_malloc(MYBUFSIZE); 405 | if (NULL == *buffer) { 406 | fprintf(stderr, "Could not allocate device memory\n"); 407 | return 1; 408 | } 409 | break; 410 | #endif 411 | default: 412 | fprintf(stderr, "Could not allocate device memory\n"); 413 | return 1; 414 | } 415 | 416 | return 0; 417 | } 418 | 419 | void * 420 | align_buffer (void * ptr, unsigned long align_size) 421 | { 422 | return (void *)(((unsigned long)ptr + (align_size - 1)) / align_size * 423 | align_size); 424 | } 425 | 426 | int 427 | allocate_memory (char ** sbuf, char ** rbuf, int rank) 428 | { 429 | unsigned long align_size = getpagesize(); 430 | 431 | assert(align_size <= MAX_ALIGNMENT); 432 | 433 | switch (rank) { 434 | case 0: 435 | if ('D' == options.src) { 436 | if (allocate_device_buffer(sbuf)) { 437 | fprintf(stderr, "Error allocating cuda memory\n"); 438 | return 1; 439 | } 440 | 441 | if (allocate_device_buffer(rbuf)) { 442 | fprintf(stderr, "Error allocating cuda memory\n"); 443 | return 1; 444 | } 445 | } 446 | 447 | else { 448 | *sbuf = align_buffer(s_buf_original, align_size); 449 | *rbuf = align_buffer(r_buf_original, align_size); 450 | } 451 | break; 452 | case 1: 453 | if ('D' == options.dst) { 454 | if (allocate_device_buffer(sbuf)) { 455 | fprintf(stderr, "Error allocating cuda memory\n"); 456 | return 1; 457 | } 458 | 459 | if (allocate_device_buffer(rbuf)) { 460 | fprintf(stderr, "Error allocating cuda memory\n"); 461 | return 1; 462 | } 463 | } 464 | 465 | else { 466 | *sbuf = align_buffer(s_buf_original, align_size); 467 | *rbuf = align_buffer(r_buf_original, align_size); 468 | } 469 | break; 470 | } 471 | 472 | return 0; 473 | } 474 | 475 | void 476 | print_header (int rank) 477 | { 478 | if (0 == rank) { 479 | switch (options.accel) { 480 | case cuda: 481 | printf(HEADER, "-CUDA"); 482 | break; 483 | case openacc: 484 | printf(HEADER, "-OPENACC"); 485 | break; 486 | default: 487 | printf(HEADER, ""); 488 | break; 489 | } 490 | 491 | switch (options.accel) { 492 | case cuda: 493 | case openacc: 494 | printf("# Send Buffer on %s and Receive Buffer on %s\n", 495 | 'D' == options.src ? "DEVICE (D)" : "HOST (H)", 496 | 'D' == options.dst ? "DEVICE (D)" : "HOST (H)"); 497 | default: 498 | printf("%-*s%*s\n", 10, "# Size", FIELD_WIDTH, "Bandwidth (MB/s)"); 499 | fflush(stdout); 500 | } 501 | } 502 | } 503 | 504 | void 505 | set_device_memory (void * ptr, int data, size_t size) 506 | { 507 | #ifdef _ENABLE_OPENACC_ 508 | size_t i; 509 | char * p = (char *)ptr; 510 | #endif 511 | 512 | switch (options.accel) { 513 | #ifdef _ENABLE_CUDA_ 514 | case cuda: 515 | cudaMemset(ptr, data, size); 516 | break; 517 | #endif 518 | #ifdef _ENABLE_OPENACC_ 519 | case openacc: 520 | #pragma acc parallel loop deviceptr(p) 521 | for(i = 0; i < size; i++) { 522 | p[i] = data; 523 | } 524 | break; 525 | #endif 526 | default: 527 | break; 528 | } 529 | } 530 | 531 | void 532 | touch_data (void * sbuf, void * rbuf, int rank, size_t size) 533 | { 534 | if ((0 == rank && 'H' == options.src) || 535 | (1 == rank && 'H' == options.dst)) { 536 | memset(sbuf, 'a', size); 537 | memset(rbuf, 'b', size); 538 | } else { 539 | set_device_memory(sbuf, 'a', size); 540 | set_device_memory(rbuf, 'b', size); 541 | } 542 | } 543 | 544 | int 545 | free_device_buffer (void * buf) 546 | { 547 | switch (options.accel) { 548 | #ifdef _ENABLE_CUDA_ 549 | case cuda: 550 | cudaFree(buf); 551 | break; 552 | #endif 553 | #ifdef _ENABLE_OPENACC_ 554 | case openacc: 555 | acc_free(buf); 556 | break; 557 | #endif 558 | default: 559 | /* unknown device */ 560 | return 1; 561 | } 562 | 563 | return 0; 564 | } 565 | 566 | int 567 | destroy_cuda_context (void) 568 | { 569 | #ifdef _ENABLE_CUDA_ 570 | CUresult curesult = CUDA_SUCCESS; 571 | curesult = cuCtxDestroy(cuContext); 572 | 573 | if (curesult != CUDA_SUCCESS) { 574 | return 1; 575 | } 576 | #endif 577 | return 0; 578 | } 579 | 580 | void 581 | free_memory (void * sbuf, void * rbuf, int rank) 582 | { 583 | switch (rank) { 584 | case 0: 585 | if ('D' == options.src) { 586 | free_device_buffer(sbuf); 587 | free_device_buffer(rbuf); 588 | } 589 | break; 590 | case 1: 591 | if ('D' == options.dst) { 592 | free_device_buffer(sbuf); 593 | free_device_buffer(rbuf); 594 | } 595 | break; 596 | } 597 | } 598 | 599 | /* vi:set sw=4 sts=4 tw=80: */ 600 | -------------------------------------------------------------------------------- /mpi_t/gyan/gyan.c: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014, Lawrence Livermore National Security, 3 | // LLC. Produced at the Lawrence Livermore National Laboratory. Written 4 | // by Tanzima Z. Islam (islam3@llnl.gov). 5 | // CODE-LLNL-CODE-647221. All rights reserved. 6 | // This file is part of mpi_T-tools. For details, see 7 | // https://computation-rnd.llnl.gov/mpi_t/gyan.php. 8 | // Please also read this file - FULL-LICENSE.txt. 9 | // This program is free software; you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License (as published by 11 | // the Free Software Foundation) version 2.1 dated February 1999. 12 | // This program is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 15 | // and conditions of the GNU General Public License for more 16 | // details. You should have received a copy of the GNU Lesser General 17 | // Public License along with this program; if not, write to the Free 18 | // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | // 02111-1307 USA 20 | ////////////////////////////////////////////////////////////////////////////// 21 | /* 22 | * gyan.c 23 | 24 | * 25 | * Created on: Jul 11, 2013 26 | * Author: Tanzima Z. Islam, (islam3@llnl.gov) 27 | */ 28 | 29 | #include "utility.h" 30 | 31 | #define THRESHOLD 0 32 | #define NOT_FOUND -1 33 | #define FALSE 0 34 | #define TRUE 1 35 | #define STR_SZ 100 36 | #define DEBUG 0 37 | #define NUM_PERF_VAR_SUPPORTED 50 38 | #define NEG_INF -10000000 39 | #define POS_INF 10000000 40 | /* Global variables for tool */ 41 | static MPI_T_pvar_session session; 42 | static MPI_T_pvar_handle *pvar_handles; 43 | static int *pvar_index; 44 | static int *pvar_count; 45 | static unsigned long long int **pvar_value_buffer; // cumulative values 46 | static void *read_value_buffer; // values are read into this buffer. 47 | static int pvar_num_watched; 48 | static int total_num_of_var; 49 | static int max_num_of_state_per_pvar = -1; // max_num_of_state_per_pvar = max(pvar_count[performance_variable]) for all performance_variables 50 | static int num_mpi_tasks; 51 | 52 | typedef struct{ 53 | int pvar_index; 54 | char *name; 55 | int name_len; 56 | int verbosity; 57 | int var_class; 58 | MPI_Datatype datatype; 59 | MPI_T_enum enumtype; 60 | char *desc; 61 | int desc_len; 62 | int binding; 63 | int readonly; 64 | int continuous; 65 | int atomic; 66 | }PERF_VAR; 67 | static PERF_VAR *perf_var_all; 68 | 69 | typedef struct{ 70 | int max_rank, min_rank; // max_rank : rank that resulted in this max value, min_rank: rank that resulted in this min value 71 | unsigned long long int max, min; // the actual max and min values 72 | unsigned long long int total; // summation of values across all MPI ranks for this particular variable 73 | // unsigned long long int freq; // how many ranks had this value? 74 | }STATISTICS; 75 | static STATISTICS **pvar_stat; 76 | 77 | typedef struct { 78 | double value; 79 | int rank; 80 | }mpi_data; 81 | 82 | static char *env_var_name; 83 | static int tool_enabled = FALSE; 84 | static int num_send, num_isend, num_recv, num_irecv; 85 | static int rank = 0; 86 | 87 | static void stop_watching(){ 88 | int i; 89 | for(i = 0; i < pvar_num_watched; i++){ 90 | MPI_T_pvar_stop(session, pvar_handles[i]); 91 | MPI_T_pvar_handle_free(session, &pvar_handles[i]); 92 | } 93 | MPI_T_pvar_session_free(&session); 94 | } 95 | 96 | static int get_watched_var_index_with_class( char *var_name, char *var_class_name ){ 97 | int i; 98 | int var_class; 99 | if( (strcmp(var_class_name, "level") == 0) || (strcmp(var_class_name, "LEVEL") == 0)) 100 | var_class = MPI_T_PVAR_CLASS_LEVEL; 101 | else if( (strcmp(var_class_name, "highwat") == 0) || (strcmp(var_class_name, "HIGHWAT") == 0)) 102 | var_class = MPI_T_PVAR_CLASS_HIGHWATERMARK; 103 | else if( (strcmp(var_class_name, "lowwat") == 0) || (strcmp(var_class_name, "LOWWAT") == 0)) 104 | var_class = MPI_T_PVAR_CLASS_LOWWATERMARK; 105 | else if( (strcmp(var_class_name, "counter") == 0) || (strcmp(var_class_name, "COUNTER") == 0)) 106 | var_class = MPI_T_PVAR_CLASS_COUNTER; 107 | else if( (strcmp(var_class_name, "state") == 0) || (strcmp(var_class_name, "STATE") == 0)) 108 | var_class = MPI_T_PVAR_CLASS_STATE; 109 | else if( (strcmp(var_class_name, "size") == 0) || (strcmp(var_class_name, "SIZE") == 0)) 110 | var_class = MPI_T_PVAR_CLASS_SIZE; 111 | else if( (strcmp(var_class_name, "percent") == 0) || (strcmp(var_class_name, "PERCENT") == 0)) 112 | var_class = MPI_T_PVAR_CLASS_PERCENTAGE; 113 | else if( (strcmp(var_class_name, "aggr") == 0) || (strcmp(var_class_name, "AGGR") == 0)) 114 | var_class = MPI_T_PVAR_CLASS_AGGREGATE; 115 | else if( (strcmp(var_class_name, "timer") == 0) || (strcmp(var_class_name, "TIMER") == 0)) 116 | var_class = MPI_T_PVAR_CLASS_TIMER; 117 | else if( (strcmp(var_class_name, "generic") == 0) || (strcmp(var_class_name, "GENERIC") == 0)) 118 | var_class = MPI_T_PVAR_CLASS_GENERIC; 119 | 120 | for(i = 0; i < total_num_of_var; i++){ 121 | if( (var_class == perf_var_all[i].var_class) && 122 | ( strcmp(var_name, perf_var_all[i].name) == 0 )) 123 | return i; 124 | } 125 | return NOT_FOUND; 126 | } 127 | 128 | static int get_watched_var_index( char *var_name){ 129 | int i; 130 | char *pch = strchr(var_name, ':'); 131 | if(pch != NULL){ 132 | // If the class is specified 133 | (*pch) = 0; 134 | return get_watched_var_index_with_class(var_name, (pch+1)); 135 | } 136 | // no class was specified 137 | for(i = 0; i < total_num_of_var; i++){ 138 | if( ( strcmp(var_name, perf_var_all[i].name) == 0 ) ) 139 | return i; 140 | } 141 | return NOT_FOUND; 142 | } 143 | 144 | /** 145 | * This function prints statistics of all performance variables monitored 146 | * @param none 147 | * @return none 148 | */ 149 | 150 | static void print_pvar_buffer_all(){ 151 | int i; 152 | int j; 153 | int index; 154 | 155 | printf("%-40s\tType ", "Variable Name"); 156 | printf(" Minimum(Rank) Maximum(Rank) Average\n"); 157 | print_filled("",88,'-'); 158 | for(i = 0; i < pvar_num_watched; i++){ 159 | index = pvar_index[i]; 160 | if(perf_var_all[index].var_class != MPI_T_PVAR_CLASS_TIMER){ 161 | for(j = 0; j < pvar_count[i]; j++){ // asuuming that pvar_count[i] on all processes was the same 162 | printf("%-40s\t", perf_var_all[index].name); 163 | print_class(perf_var_all[index].var_class); 164 | printf("\t%8llu(%3d) %8llu(%3d) %12.2lf\n", pvar_stat[i][j].min, pvar_stat[i][j].min_rank, 165 | pvar_stat[i][j].max, pvar_stat[i][j].max_rank, 166 | (pvar_stat[i][j].total / (double)num_mpi_tasks)); 167 | } 168 | } 169 | } 170 | } 171 | 172 | static void pvar_read_all(){ 173 | int i, j; 174 | int size; 175 | unsigned long long int zero = 0; 176 | for(i = 0; i < pvar_num_watched; i++){ 177 | MPI_T_pvar_read(session, pvar_handles[i], read_value_buffer); 178 | MPI_Type_size(perf_var_all[i].datatype, &size); 179 | for(j = 0; j < pvar_count[j]; j++){ 180 | pvar_value_buffer[i][j] = 0; 181 | memcpy(&(pvar_value_buffer[i][j]), read_value_buffer, size); 182 | } 183 | } 184 | return; 185 | } 186 | 187 | 188 | static void clean_up_perf_var_all(int num_of_perf_var){ 189 | int i; 190 | for(i = 0; i < num_of_perf_var; i++){ 191 | free(perf_var_all[i].name); 192 | free(perf_var_all[i].desc); 193 | } 194 | free(perf_var_all); 195 | } 196 | 197 | static void clean_up_pvar_value_buffer(int num_of_var_watched){ 198 | int i; 199 | for(i = 0; i < num_of_var_watched; i++){ 200 | free(pvar_value_buffer[i]); 201 | } 202 | free(pvar_value_buffer); 203 | } 204 | 205 | static void clean_up_the_rest(){ 206 | free(read_value_buffer); 207 | free(pvar_handles); 208 | free(pvar_index); 209 | free(pvar_count); 210 | } 211 | 212 | static void collect_sum_from_all_ranks(MPI_Op op){ 213 | int i; 214 | int j; 215 | int root = 0; 216 | 217 | unsigned long long int *value_in; 218 | unsigned long long int *value_out; 219 | value_in = (unsigned long long int*)malloc(sizeof(unsigned long long int) * ( max_num_of_state_per_pvar + 1)); 220 | if(rank == root) 221 | value_out = (unsigned long long int*)malloc(sizeof(unsigned long long int) * ( max_num_of_state_per_pvar + 1)); 222 | 223 | for(i = 0; i < pvar_num_watched; i++){ 224 | for(j = 0; j < pvar_count[i]; j++){ 225 | value_in[j] = pvar_value_buffer[i][j]; 226 | } 227 | PMPI_Reduce(value_in, value_out, pvar_count[i] /*number_of_elements*/, MPI_UNSIGNED_LONG_LONG, op, root, MPI_COMM_WORLD); 228 | if(root == rank){ 229 | /** 230 | * Populate these values into the pvar_stat array of rank 0. 231 | */ 232 | for(j = 0; j < pvar_count[i]; j++){ 233 | pvar_stat[i][j].total = value_out[j]; 234 | } 235 | }// root is done extracting information from "out" to pvar_stat 236 | } 237 | free(value_in); 238 | if(root == rank) 239 | free(value_out); 240 | } 241 | 242 | static void collect_range_with_loc_from_all_ranks(MPI_Op op){ 243 | int i; 244 | int j; 245 | int root = 0; 246 | mpi_data *in; 247 | mpi_data *out; 248 | 249 | /** 250 | * Pack all variables into a buffer 251 | */ 252 | /** 253 | * MPI_Reduce on each element. Each element here is a performance variable 254 | */ 255 | in = (mpi_data*)malloc(sizeof(mpi_data) * ( max_num_of_state_per_pvar + 1)); 256 | if(rank == root) 257 | out = (mpi_data*)malloc(sizeof(mpi_data) * (max_num_of_state_per_pvar + 1)); 258 | for(i = 0; i < pvar_num_watched; i++){ 259 | for(j = 0; j < pvar_count[i]; j++){ 260 | in[j].value = 0; 261 | in[j].value = (double)(pvar_value_buffer[i][j]); 262 | in[j].rank = rank; 263 | } 264 | PMPI_Reduce(in, out, pvar_count[i] /*number_of_elements*/, MPI_DOUBLE_INT, op, root, MPI_COMM_WORLD); 265 | //printout 266 | if(root == rank){ 267 | for(j = 0; j < pvar_count[i]; j++){ 268 | if(op == MPI_MINLOC){ 269 | pvar_stat[i][j].min = (unsigned long long int)(out[j].value); 270 | pvar_stat[i][j].min_rank = out[j].rank; 271 | } 272 | else if(op == MPI_MAXLOC){ 273 | pvar_stat[i][j].max = (unsigned long long int)(out[j].value); 274 | pvar_stat[i][j].max_rank = out[j].rank; 275 | } 276 | } 277 | } 278 | } 279 | free(in); 280 | if(root == rank) 281 | free(out); 282 | } 283 | 284 | int MPI_Init(int *argc, char ***argv){ 285 | 286 | if(DEBUG)printf("********** Interception starts **********\n"); 287 | int err, num, i, namelen, verb, varclass, bind, threadsup; 288 | int index; 289 | int readonly, continuous, atomic; 290 | char name[STR_SZ + 1] = ""; 291 | int desc_len; 292 | char desc[STR_SZ + 1] = ""; 293 | int mpi_init_return; 294 | MPI_Datatype datatype; 295 | MPI_T_enum enumtype; 296 | 297 | /* Run MPI Initialization */ 298 | mpi_init_return = PMPI_Init(argc, argv); 299 | if (mpi_init_return != MPI_SUCCESS) 300 | return mpi_init_return; 301 | 302 | /* get global rank */ 303 | PMPI_Comm_rank(MPI_COMM_WORLD, &rank); 304 | 305 | /* get number of tasks*/ 306 | PMPI_Comm_size(MPI_COMM_WORLD, &num_mpi_tasks); 307 | 308 | /* Run MPI_T Initialization */ 309 | err = MPI_T_init_thread(MPI_THREAD_SINGLE, &threadsup); 310 | if (err != MPI_SUCCESS) 311 | return mpi_init_return; 312 | 313 | /* Print thread support for MPI */ 314 | if(!rank) { 315 | print_filled("",88,'-'); 316 | printf("MPI_T Thread support: "); 317 | switch (threadsup) { 318 | case MPI_THREAD_SINGLE: 319 | printf("MPI_THREAD_SINGLE\n"); 320 | break; 321 | case MPI_THREAD_FUNNELED: 322 | printf("MPI_THREAD_FUNNELED\n"); 323 | break; 324 | case MPI_THREAD_SERIALIZED: 325 | printf("MPI_THREAD_SERIALIZED\n"); 326 | break; 327 | case MPI_THREAD_MULTIPLE: 328 | printf("MPI_THREAD_MULTIPLE\n"); 329 | break; 330 | default: 331 | printf("unknown (%i)\n",threadsup); 332 | } 333 | } 334 | 335 | 336 | /* Create a session */ 337 | err = MPI_T_pvar_session_create(&session); 338 | if (err != MPI_SUCCESS) 339 | return mpi_init_return; 340 | 341 | /* get number of variables */ 342 | err = MPI_T_pvar_get_num(&num); 343 | if(!rank) { 344 | printf("%d performance variables exposed by this MPI library\n",num); 345 | print_filled("",88,'-'); 346 | } 347 | 348 | if (err != MPI_SUCCESS) 349 | return mpi_init_return; 350 | total_num_of_var = num; 351 | // Get the name of the environment variable to look for 352 | env_var_name = getenv("MPIT_VAR_TO_TRACE"); 353 | int set_default = 0; 354 | if( (env_var_name != NULL )){ 355 | if(DEBUG)printf("Environment variable set: %s\n", env_var_name); 356 | if(strlen(env_var_name) == 0){ 357 | set_default = 1; 358 | } 359 | } 360 | else{ 361 | set_default = 1; 362 | } 363 | 364 | /* Allocate handles for all performance variables*/ 365 | pvar_handles = (MPI_T_pvar_handle*)malloc(sizeof(MPI_T_pvar_handle) * (num + 1)); 366 | pvar_index = (int*)malloc(sizeof(int) * (num + 1)); 367 | pvar_count = (int*)malloc(sizeof(int) * (num + 1)); 368 | memset(pvar_count, 0, sizeof(int) * (num + 1)); 369 | perf_var_all = (PERF_VAR*)malloc(sizeof(PERF_VAR) * (num + 1)); 370 | pvar_stat = (STATISTICS**)malloc(sizeof(STATISTICS*) * (num + 1)); 371 | int total_length_pvar_name = 0; 372 | for(i = 0; i < num; i++){ 373 | namelen = desc_len = STR_SZ; 374 | err = MPI_T_pvar_get_info(i/*IN*/, 375 | name /*OUT*/, 376 | &namelen /*INOUT*/, 377 | &verb /*OUT*/, 378 | &varclass /*OUT*/, 379 | &datatype /*OUT*/, 380 | &enumtype /*OUT*/, 381 | desc /*desc: OUT*/, 382 | &desc_len /*desc_len: INOUT*/, 383 | &bind /*OUT*/, 384 | &readonly /*OUT*/, 385 | &continuous /*OUT*/, 386 | &atomic/*OUT*/); 387 | perf_var_all[i].pvar_index = -1; // gets setup later 388 | perf_var_all[i].name_len = namelen; 389 | perf_var_all[i].name = (char*)malloc(sizeof(char) * (namelen + 1)); 390 | strcpy(perf_var_all[i].name, name); 391 | total_length_pvar_name += namelen; 392 | 393 | perf_var_all[i].verbosity = verb; 394 | perf_var_all[i].var_class = varclass; 395 | perf_var_all[i].datatype = datatype; 396 | perf_var_all[i].enumtype = enumtype; 397 | perf_var_all[i].desc_len = desc_len; 398 | perf_var_all[i].desc = (char*)malloc(sizeof(char) * (desc_len + 1)); 399 | strcpy(perf_var_all[i].desc, desc); 400 | perf_var_all[i].binding = bind; 401 | perf_var_all[i].readonly = readonly; 402 | perf_var_all[i].continuous = continuous; 403 | perf_var_all[i].atomic = atomic; 404 | } 405 | 406 | if(set_default == 1){ 407 | /*By default, watch all variables in the list.*/ 408 | //env_var_name = get_pvars_name_list(); 409 | /* Allocate string buffers */ 410 | 411 | env_var_name = (char*)malloc(sizeof(char)* (total_length_pvar_name + num * 8 /*strlen(:CLASS_NAME)*/ + num /*delimiter*/ + 1)); 412 | int index = 0; 413 | char *class_name; 414 | for (i = 0; i < num; i++) 415 | { 416 | memcpy((env_var_name + index), perf_var_all[i].name, strlen(perf_var_all[i].name)); 417 | index += (strlen(perf_var_all[i].name) ); 418 | memcpy((env_var_name + index), ":", strlen(":")); 419 | index += (strlen(":")); 420 | class_name = get_pvar_class(perf_var_all[i].var_class); 421 | memcpy((env_var_name + index), class_name, strlen(class_name)); 422 | index += (strlen(class_name)); 423 | memcpy((env_var_name + index), ";", strlen(";")); 424 | index += (strlen(";")); 425 | } 426 | env_var_name[index] = 0; 427 | } 428 | 429 | /* Now, start session for those variables in the watchlist*/ 430 | pvar_num_watched = 0; 431 | char *p = strtok(env_var_name, ";"); 432 | pvar_value_buffer = (unsigned long long int**)malloc(sizeof(unsigned long long int*) * (num + 1)); 433 | int max_count = -1; 434 | int k; 435 | while(p != NULL){ 436 | index = get_watched_var_index(p); 437 | if(index != NOT_FOUND){ 438 | pvar_index[pvar_num_watched] = index; 439 | perf_var_all[index].pvar_index = pvar_num_watched; 440 | err = MPI_T_pvar_handle_alloc(session, index, NULL, &pvar_handles[pvar_num_watched], &pvar_count[pvar_num_watched]); 441 | if (err == MPI_SUCCESS){ 442 | pvar_value_buffer[pvar_num_watched] = (unsigned long long int*)malloc(sizeof(unsigned long long int) * (pvar_count[pvar_num_watched] + 1)); 443 | pvar_stat[pvar_num_watched] = (STATISTICS*)malloc(sizeof(STATISTICS) * (pvar_count[pvar_num_watched] + 1)); 444 | memset(pvar_value_buffer[pvar_num_watched], 0, sizeof(unsigned long long int) * pvar_count[pvar_num_watched]); 445 | for(k = 0; k < pvar_count[pvar_num_watched]; k++){ 446 | pvar_value_buffer[pvar_num_watched][k] = 0; 447 | pvar_stat[pvar_num_watched][k].max = NEG_INF; 448 | pvar_stat[pvar_num_watched][k].min = POS_INF; 449 | pvar_stat[pvar_num_watched][k].total = 0; 450 | 451 | } 452 | if(max_count < pvar_count[pvar_num_watched]) 453 | max_count = pvar_count[pvar_num_watched]; 454 | 455 | if(perf_var_all[index].continuous == 0){ 456 | err = MPI_T_pvar_start(session, pvar_handles[pvar_num_watched]); 457 | } 458 | if (err != MPI_SUCCESS) { 459 | return mpi_init_return; 460 | } 461 | pvar_num_watched++; 462 | } 463 | } 464 | p = strtok(NULL, ";"); 465 | } 466 | read_value_buffer = (void*)malloc(sizeof(unsigned long long int) * (max_count + 1)); 467 | max_num_of_state_per_pvar = max_count; 468 | 469 | assert(num >= pvar_num_watched); 470 | assert(pvar_value_buffer != NULL); 471 | /* iterate unit variable is found */ 472 | tool_enabled = TRUE; 473 | num_send = 0; 474 | num_isend = 0; 475 | num_recv = 0; 476 | num_irecv = 0; 477 | return mpi_init_return; 478 | } 479 | 480 | int MPI_Finalize(void) 481 | { 482 | pvar_read_all(); 483 | /** 484 | * Collect statistics from all ranks onto root 485 | */ 486 | collect_range_with_loc_from_all_ranks(MPI_MINLOC); 487 | collect_range_with_loc_from_all_ranks(MPI_MAXLOC); 488 | collect_sum_from_all_ranks(MPI_SUM); 489 | 490 | if(rank == 0){ 491 | print_filled("",88,'-'); 492 | printf("Performance profiling for the complete MPI job:\n"); 493 | print_filled("",88,'-'); 494 | print_pvar_buffer_all(); 495 | print_filled("",88,'-'); 496 | } 497 | stop_watching(); 498 | clean_up_perf_var_all(total_num_of_var); 499 | clean_up_pvar_value_buffer(pvar_num_watched); 500 | clean_up_the_rest(); 501 | PMPI_Barrier(MPI_COMM_WORLD); 502 | MPI_T_finalize(); 503 | return PMPI_Finalize(); 504 | } 505 | -------------------------------------------------------------------------------- /mpi_t/gyan/FULL-LICENSE.txt: -------------------------------------------------------------------------------- 1 | OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE 2 | Our Preamble Notice 3 | A. This notice is required to be provided under our contract with the U.S. Department of Energy (DOE). This work was produced at the Lawrence Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE. 4 | B. Neither the United States Government nor Lawrence Livermore National Security, LLC nor any of their employees, makes any warranty, express or implied, or assumes 5 | any liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately-owned rights. 6 |  7 | C. Also, reference herein to any specific commercial products, process, or services by trade name, trademark, manufacturer or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or Lawrence Livermore National Security, LLC. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or Lawrence Livermore National Security, LLC, and shall not be used for advertising or product endorsement purposes. 8 | The precise terms and conditions for copying, distribution and modification follows. 9 | GNU Lesser GPL terms and Conditions for Copying, Distribution, and Modification 10 | 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called “this License”). Each licensee is addressed as “you”. 11 | A “library” means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. 12 | The “Library”, below, refers to any such software library or work which has been distributed under these terms. A “work based on the Library” means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term “modification”.) 13 | “Source code” for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. 14 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 15 | 1. You may copy and distribute verbatim copies of the Library’s complete source 16 |  17 | code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. 18 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 19 | 2 You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 20 | a) The modified work must itself be a software library. 21 | b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 22 | c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. 23 | d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. 24 | (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) 25 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 26 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. 27 | In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 28 | 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. 29 | Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. 30 | This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 31 | 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine- readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. 32 | If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 33 | 2 A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a “work that uses the Library”. Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. 34 | However, linking a “work that uses the Library” with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a “work that uses the library”. The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. 35 | When a “work that uses the Library” uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. 36 | If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under section 6.) 37 | Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 38 | 6. As an exception to the Sections above, you may also combine or link a “work that uses the Library” with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer’s own use and reverse engineering for debugging such modifications. 39 | You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: 40 | a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable liked with the Library, with the complete machine-readable “work that uses the Library”, as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) 41 | b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already 42 | present on the user’s computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface- compatible with the version that the work was made with. 43 | c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. 44 | d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. 45 | e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. 46 | For an executable, the required form of the “work that uses the Library” must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 47 | It may happen that this requirement contradicts the license restrictions of other propriety libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 48 | 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: 49 | a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. 50 | b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 51 | 1 You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 52 | 2 You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 53 | 3 Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 54 | 4 If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. 55 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. 56 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 57 | This section is intended to make thoroughly clear what is believed to be a consequence 58 | of the rest of this License. 59 | 1 If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 60 | 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 61 | Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 62 | 2 If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 63 | write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 64 | NO WARRANTY 65 | 1 BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 66 | 2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE 67 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 68 | -------------------------------------------------------------------------------- /mpi_t/varlist/FULL-LICENSE.txt: -------------------------------------------------------------------------------- 1 | OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE 2 | Our Preamble Notice 3 | A. This notice is required to be provided under our contract with the U.S. Department of Energy (DOE). This work was produced at the Lawrence Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE. 4 | B. Neither the United States Government nor Lawrence Livermore National Security, LLC nor any of their employees, makes any warranty, express or implied, or assumes 5 | any liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately-owned rights. 6 |  7 | C. Also, reference herein to any specific commercial products, process, or services by trade name, trademark, manufacturer or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or Lawrence Livermore National Security, LLC. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or Lawrence Livermore National Security, LLC, and shall not be used for advertising or product endorsement purposes. 8 | The precise terms and conditions for copying, distribution and modification follows. 9 | GNU Lesser GPL terms and Conditions for Copying, Distribution, and Modification 10 | 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called “this License”). Each licensee is addressed as “you”. 11 | A “library” means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. 12 | The “Library”, below, refers to any such software library or work which has been distributed under these terms. A “work based on the Library” means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term “modification”.) 13 | “Source code” for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. 14 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 15 | 1. You may copy and distribute verbatim copies of the Library’s complete source 16 |  17 | code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. 18 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 19 | 2 You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 20 | a) The modified work must itself be a software library. 21 | b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 22 | c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. 23 | d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. 24 | (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) 25 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 26 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. 27 | In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 28 | 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. 29 | Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. 30 | This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 31 | 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine- readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. 32 | If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 33 | 2 A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a “work that uses the Library”. Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. 34 | However, linking a “work that uses the Library” with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a “work that uses the library”. The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. 35 | When a “work that uses the Library” uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. 36 | If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under section 6.) 37 | Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 38 | 6. As an exception to the Sections above, you may also combine or link a “work that uses the Library” with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer’s own use and reverse engineering for debugging such modifications. 39 | You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: 40 | a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable liked with the Library, with the complete machine-readable “work that uses the Library”, as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) 41 | b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already 42 | present on the user’s computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface- compatible with the version that the work was made with. 43 | c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. 44 | d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. 45 | e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. 46 | For an executable, the required form of the “work that uses the Library” must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 47 | It may happen that this requirement contradicts the license restrictions of other propriety libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 48 | 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: 49 | a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. 50 | b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 51 | 1 You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 52 | 2 You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 53 | 3 Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 54 | 4 If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. 55 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. 56 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 57 | This section is intended to make thoroughly clear what is believed to be a consequence 58 | of the rest of this License. 59 | 1 If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 60 | 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 61 | Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 62 | 2 If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 63 | write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 64 | NO WARRANTY 65 | 1 BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 66 | 2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE 67 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 68 | -------------------------------------------------------------------------------- /mpi_t/varlist/varlist.c: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014, Lawrence Livermore National Security, 3 | // LLC. Produced at the Lawrence Livermore National Laboratory. Written 4 | // by Martin Schulz (schulzm@llnl.gov). CODE-LLNL-CODE-647221. All rights 5 | // reserved. This file is part of mpi_T-tools. For details, see 6 | // https://computation-rnd.llnl.gov/mpi_t/varList.php. Please also read 7 | // this file - ./FULL-LICENSE.txt. 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License (as published by 10 | // the Free Software Foundation) version 2.1 dated February 1999. 11 | // This program is distributed in the hope that it will be useful, but 12 | // WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and 14 | // conditions of the GNU General Public License for more details. You 15 | // should have received a copy of the GNU Lesser General Public License 16 | // along with this program; if not, write to the Free Software 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 | // USA 19 | ////////////////////////////////////////////////////////////////////////////// 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #define SCREENLEN 78 29 | 30 | #ifndef MPI_COUNT 31 | #define MPI_COUNT MPI_INT 32 | typedef int MPI_Count; 33 | #endif 34 | 35 | #ifndef MPI_T_CVAR_HANDLE_NULL 36 | #define MPI_T_CVAR_HANDLE_NULL NULL 37 | #endif 38 | char errMsg[1000]; 39 | int errMsgLen; 40 | #define CHECKERR(errstr,err) if (err!=MPI_SUCCESS) { printf("ERROR: %s: MPI error code %i: ",errstr,err); MPI_Error_string(err, errMsg, &errMsgLen); errMsg[errMsgLen]=0; printf("%s\n", errMsg); /*usage(1);*/ } 41 | 42 | int list_pvar,list_cvar,longlist,verbosity,runmpi; 43 | 44 | #define RUNMPI 1 45 | 46 | /* Usage */ 47 | 48 | void usage(int e) 49 | { 50 | printf("Usage: varlist [-c] [-p] [-v ] [-l] [-m]\n"); 51 | printf(" -c = List only Control Variables\n"); 52 | printf(" -p = List only Performance Variables\n"); 53 | printf(" -v = List up to verbosity level (1=U/B to 9=D/D)\n"); 54 | printf(" -l = Long list with all information, incl. descriptions\n"); 55 | printf(" -m = Do not call MPI_Init before listing variables\n"); 56 | printf(" -h = This help text\n"); 57 | exit(e); 58 | } 59 | 60 | 61 | /* Print a filled string */ 62 | 63 | void print_filled(char *s, int len, char c) 64 | { 65 | int i; 66 | printf("%s",s); 67 | for (i=strlen(s); imaxnamelen) maxnamelen=namelen; 354 | if (desclen>maxdesclen) maxdesclen=desclen; 355 | if (verbos<=verbosity) numvars++; 356 | } 357 | 358 | printf("Found %i performance variables with verbosity <= ",numvars); 359 | print_verbosity_short(verbosity); 360 | printf("\n\n"); 361 | 362 | 363 | /* Allocate string buffers */ 364 | 365 | name=(char*)malloc(sizeof(char)*maxnamelen); 366 | CHECKERR("Malloc Name",name==NULL); 367 | desc=(char*)malloc(sizeof(char)*maxdesclen); 368 | CHECKERR("Malloc Desc",desc==NULL); 369 | 370 | /* Print header */ 371 | 372 | prtlen=0; 373 | if (!longlist) 374 | { 375 | print_filled("Variable",maxnamelen,' '); 376 | printf(" "); 377 | prtlen=maxnamelen+1; 378 | printf("VRB "); 379 | printf(" "); 380 | prtlen+=5+1; 381 | printf("Class "); 382 | printf(" "); 383 | prtlen+=7+1; 384 | printf("Type "); 385 | printf(" "); 386 | prtlen+=6+1; 387 | printf("Bind "); 388 | printf(" "); 389 | prtlen+=8+1; 390 | printf("R/O"); 391 | printf(" "); 392 | prtlen+=3+1; 393 | printf("CNT"); 394 | printf(" "); 395 | prtlen+=3+1; 396 | printf("ATM"); 397 | printf("\n"); 398 | prtlen+=3; 399 | print_filled("",prtlen,'-');printf("\n"); 400 | } 401 | 402 | 403 | /* Loop and print */ 404 | 405 | for (i=0; i0) 450 | { 451 | if (!longlist) 452 | { 453 | print_filled("",prtlen,'-');printf("\n"); 454 | } 455 | else 456 | { 457 | print_filled("",SCREENLEN,'-');printf("\n"); 458 | } 459 | } 460 | 461 | 462 | /* free buffers */ 463 | 464 | free(name); 465 | free(desc); 466 | } 467 | 468 | 469 | /* Print all Control Variables */ 470 | 471 | void list_cvars() 472 | { 473 | int num,err,i,numvars; 474 | char *name, *desc; 475 | int bind,verbos,scope; 476 | MPI_Datatype dt; 477 | MPI_T_enum et; 478 | int maxnamelen=strlen("Variable"); 479 | int maxdesclen=0; 480 | int prtlen; 481 | int namelen,desclen; 482 | 483 | int v_int; 484 | unsigned int v_uint; 485 | unsigned long v_ulong; 486 | unsigned long long v_ullong; 487 | MPI_Count v_count; 488 | char v_char[4097]; 489 | double v_double; 490 | char value[257]; 491 | int value_sup; 492 | MPI_T_cvar_handle handle=MPI_T_CVAR_HANDLE_NULL; 493 | int count; 494 | 495 | /* Get number of variables */ 496 | 497 | err=MPI_T_cvar_get_num(&num); 498 | CHECKERR("CVARNUM",err); 499 | printf("Found %i control variables\n",num); 500 | 501 | 502 | /* Find string sizes */ 503 | 504 | numvars=0; 505 | 506 | for (i=0; imaxnamelen) maxnamelen=namelen; 514 | if (desclen>maxdesclen) maxdesclen=desclen; 515 | if (verbos<=verbosity) numvars++; 516 | } 517 | 518 | printf("Found %i control variables with verbosity <= ",numvars); 519 | print_verbosity_short(verbosity); 520 | printf("\n\n"); 521 | 522 | /* Allocate string buffers */ 523 | 524 | name=(char*)malloc(sizeof(char)*maxnamelen); 525 | CHECKERR("Malloc Name",name==NULL); 526 | desc=(char*)malloc(sizeof(char)*maxdesclen); 527 | CHECKERR("Malloc Desc",desc==NULL); 528 | 529 | 530 | /* Print header */ 531 | 532 | prtlen=0; 533 | if (!longlist) 534 | { 535 | print_filled("Variable",maxnamelen,' '); 536 | printf(" "); 537 | prtlen=maxnamelen+1; 538 | printf("VRB "); 539 | printf(" "); 540 | prtlen+=5+1; 541 | printf("Type "); 542 | printf(" "); 543 | prtlen+=6+1; 544 | printf("Bind "); 545 | printf(" "); 546 | prtlen+=8+1; 547 | printf("Scope "); 548 | printf(" "); 549 | prtlen+=8+1; 550 | printf("Value"); 551 | printf("\n"); 552 | prtlen+=12; 553 | print_filled("",prtlen,'-');printf("\n"); 554 | } 555 | 556 | 557 | /* Loop and print */ 558 | 559 | for (i=0; i0) 711 | { 712 | if (!longlist) 713 | { 714 | print_filled("",prtlen,'-');printf("\n"); 715 | } 716 | else 717 | { 718 | print_filled("",SCREENLEN,'-');printf("\n"); 719 | } 720 | } 721 | 722 | 723 | /* free buffers */ 724 | 725 | free(name); 726 | free(desc); 727 | } 728 | 729 | 730 | /* Main */ 731 | 732 | int main(int argc, char *argv[]) 733 | { 734 | int err,errarg; 735 | int threadsupport,threadsupport_t; 736 | int rank; 737 | int opt,erropt; 738 | int reqthread=MPI_THREAD_MULTIPLE; 739 | 740 | int minor,major; 741 | 742 | char libversion[MPI_MAX_LIBRARY_VERSION_STRING]; 743 | int libversionlen; 744 | 745 | 746 | /* Read options */ 747 | 748 | verbosity=MPI_T_VERBOSITY_MPIDEV_ALL; 749 | list_pvar=1; 750 | list_cvar=1; 751 | longlist=0; 752 | runmpi=1; 753 | errarg=0; 754 | 755 | while ((opt=getopt(argc,argv, "hv:pclim")) != -1 ) { 756 | switch (opt) { 757 | case 'h': 758 | errarg=-1; 759 | break; 760 | case 'v': 761 | switch (atoi(optarg)) { 762 | case 1: verbosity=MPI_T_VERBOSITY_USER_BASIC; break; 763 | case 2: verbosity=MPI_T_VERBOSITY_USER_DETAIL; break; 764 | case 3: verbosity=MPI_T_VERBOSITY_USER_ALL; break; 765 | case 4: verbosity=MPI_T_VERBOSITY_TUNER_BASIC; break; 766 | case 5: verbosity=MPI_T_VERBOSITY_TUNER_DETAIL; break; 767 | case 6: verbosity=MPI_T_VERBOSITY_TUNER_ALL; break; 768 | case 7: verbosity=MPI_T_VERBOSITY_MPIDEV_BASIC; break; 769 | case 8: verbosity=MPI_T_VERBOSITY_MPIDEV_DETAIL; break; 770 | case 9: verbosity=MPI_T_VERBOSITY_MPIDEV_ALL; break; 771 | } 772 | break; 773 | case 'p': 774 | list_pvar=1; 775 | list_cvar=0; 776 | break; 777 | case 'c': 778 | list_cvar=1; 779 | list_pvar=0; 780 | break; 781 | case 'l': 782 | longlist=1; 783 | break; 784 | case 'm': 785 | runmpi=0; 786 | break; 787 | default: 788 | errarg=1; 789 | erropt=opt; 790 | break; 791 | } 792 | } 793 | 794 | /* Initialize */ 795 | 796 | if (runmpi) 797 | { 798 | err=MPI_Init_thread(&argc,&argv,reqthread,&threadsupport); 799 | CHECKERR("Init",err); 800 | 801 | err=MPI_Comm_rank(MPI_COMM_WORLD,&rank); 802 | CHECKERR("Rank",err); 803 | } 804 | else 805 | rank=0; 806 | 807 | 808 | /* ONLY FOR RANK 0 */ 809 | 810 | if (rank==0) 811 | { 812 | err=MPI_T_init_thread(reqthread, &threadsupport_t); 813 | CHECKERR("T_Init",err); 814 | 815 | if (errarg) 816 | { 817 | if (errarg>0) 818 | printf("Argument error: %c\n",erropt); 819 | usage(errarg!=-1); 820 | } 821 | 822 | 823 | /* Header */ 824 | 825 | printf("MPI_T Variable List\n\n"); 826 | 827 | /* Print Version */ 828 | 829 | err=MPI_Get_version(&major,&minor); 830 | CHECKERR("T_Init",err); 831 | printf(" MPI Version: %i.%i\n",major,minor); 832 | 833 | err=MPI_Get_library_version(libversion,&libversionlen); 834 | CHECKERR("T_Init",err); 835 | printf(" MPI Library Version: %s\n\n",libversion); 836 | 837 | /* Print thread support */ 838 | 839 | if (runmpi) 840 | { 841 | /* Print thread support for MPI */ 842 | 843 | printf(" MPI Thread support: "); 844 | switch (threadsupport) { 845 | case MPI_THREAD_SINGLE: 846 | printf("MPI_THREAD_SINGLE\n"); 847 | break; 848 | case MPI_THREAD_FUNNELED: 849 | printf("MPI_THREAD_FUNNELED\n"); 850 | break; 851 | case MPI_THREAD_SERIALIZED: 852 | printf("MPI_THREAD_SERIALIZED\n"); 853 | break; 854 | case MPI_THREAD_MULTIPLE: 855 | printf("MPI_THREAD_MULTIPLE\n"); 856 | break; 857 | default: 858 | printf("unknown (%i)\n",threadsupport); 859 | } 860 | } 861 | 862 | /* Print thread support for MPI_T */ 863 | 864 | printf(" MPI_T Thread support: "); 865 | switch (threadsupport_t) { 866 | case MPI_THREAD_SINGLE: 867 | printf("MPI_THREAD_SINGLE\n"); 868 | break; 869 | case MPI_THREAD_FUNNELED: 870 | printf("MPI_THREAD_FUNNELED\n"); 871 | break; 872 | case MPI_THREAD_SERIALIZED: 873 | printf("MPI_THREAD_SERIALIZED\n"); 874 | break; 875 | case MPI_THREAD_MULTIPLE: 876 | printf("MPI_THREAD_MULTIPLE\n"); 877 | break; 878 | default: 879 | printf("unknown (%i)\n",threadsupport_t); 880 | } 881 | 882 | /* Start MPI_T */ 883 | 884 | 885 | if (list_cvar) 886 | { 887 | printf("\n===============================\n"); 888 | printf("Control Variables"); 889 | printf("\n===============================\n\n"); 890 | list_cvars(); 891 | printf("\n"); 892 | } 893 | 894 | if (list_pvar) 895 | { 896 | printf("\n===============================\n"); 897 | printf("Performance Variables"); 898 | printf("\n===============================\n\n"); 899 | list_pvars(); 900 | printf("\n"); 901 | } 902 | } 903 | 904 | /* Clean up */ 905 | 906 | if (runmpi) 907 | { 908 | err=MPI_Barrier(MPI_COMM_WORLD); 909 | CHECKERR("Barrier",err); 910 | } 911 | 912 | if (rank==0) 913 | MPI_T_finalize(); 914 | 915 | if (runmpi) 916 | MPI_Finalize(); 917 | 918 | if (rank==0) 919 | printf("Done.\n"); 920 | 921 | return 0; 922 | } 923 | 924 | --------------------------------------------------------------------------------