root/ompi/debuggers/predefined_gap_test.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2009      Sun Microsystems, Inc  All rights reserved.
   3  * Copyright (c) 2009-2013 Cisco Systems, Inc.  All rights reserved.
   4  * Copyright (c) 2012-2013 The University of Tennessee and The University
   5  *                         of Tennessee Research Foundation.  All rights
   6  *                         reserved.
   7  * Copyright (c) 2012-2013 Inria.  All rights reserved.
   8  * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
   9  * $COPYRIGHT$
  10  *
  11  * Additional copyrights may follow
  12  *
  13  * $HEADER$
  14  */
  15 
  16 #include "ompi_config.h"
  17 #include "ompi/communicator/communicator.h"
  18 #include "ompi/group/group.h"
  19 #include "ompi/request/request.h"
  20 #include "ompi/op/op.h"
  21 #include "ompi/datatype/ompi_datatype.h"
  22 #include "ompi/win/win.h"
  23 #include "ompi/info/info.h"
  24 #include "ompi/file/file.h"
  25 
  26 #include <stdlib.h>
  27 
  28 /*
  29  * See if there is a gap between two fields in a given struct
  30  */
  31 #define GAP_CHECK(NAME, BASE, F1, F2, CGAP) \
  32     {                                                                   \
  33         offset = (size_t)&BASE.F1 - (size_t)&BASE;                      \
  34         exp_offset = ((size_t)&BASE.F2 - (size_t)&BASE) + sizeof(BASE.F2); \
  35         printf(NAME " offset from base = %lu, sizeof %lu ", offset, sizeof(BASE.F1)); \
  36         if (CGAP && offset != exp_offset) {                             \
  37             printf("(*** gap between " #F1 " and " #F2 " ***)");        \
  38         }                                                               \
  39         printf("\n");                                                   \
  40     }
  41 
  42 
  43 int main(int argc, char **argv) {
  44     ompi_communicator_t test_comm;
  45     ompi_group_t test_group;
  46     ompi_request_t test_req;
  47     ompi_op_t test_op;
  48     ompi_win_t test_win;
  49     ompi_info_t test_info;
  50     ompi_file_t test_file;
  51     size_t exp_offset, offset;
  52 
  53     /* Test Predefined communicator sizes */
  54     printf("ompi_predefined_communicator_t = %lu bytes\n", sizeof(ompi_predefined_communicator_t));
  55     printf("ompi_communicator_t = %lu bytes\n", sizeof(ompi_communicator_t));
  56     GAP_CHECK("c_base", test_comm, super, super, 0);
  57     GAP_CHECK("c_lock", test_comm, c_lock, super, 1);
  58     GAP_CHECK("c_name", test_comm, c_name, c_lock, 1);
  59     GAP_CHECK("c_contextid", test_comm, c_contextid, c_name, 1);
  60     GAP_CHECK("c_my_rank", test_comm, c_my_rank, c_contextid, 1);
  61     GAP_CHECK("c_flags", test_comm, c_flags, c_my_rank, 1);
  62     GAP_CHECK("c_id_available", test_comm, c_id_available, c_flags, 1);
  63     GAP_CHECK("c_id_start_index", test_comm, c_id_start_index, c_id_available,  1);
  64     GAP_CHECK("c_remote_group", test_comm, c_remote_group, c_local_group, 1);
  65     GAP_CHECK("c_local_comm", test_comm, c_local_comm,  c_remote_group,  1);
  66     GAP_CHECK("c_keyhash", test_comm, c_keyhash, c_local_comm,  1);
  67     GAP_CHECK("c_cube_dim", test_comm, c_cube_dim, c_keyhash,  1);
  68     GAP_CHECK("c_topo", test_comm, c_topo, c_cube_dim,  1);
  69     GAP_CHECK("c_f_to_c_index", test_comm, c_f_to_c_index, c_topo, 1);
  70 #ifdef OMPI_WANT_PERUSE
  71     GAP_CHECK("c_peruse_handles", test_comm, c_peruse_handles, c_f_to_c_index, 1);
  72     GAP_CHECK("error_handler", test_comm, error_handler, c_peruse_handles, 1);
  73 #else
  74     GAP_CHECK("error_handler", test_comm, error_handler, c_f_to_c_index, 1);
  75 #endif
  76     GAP_CHECK("errhandler_type", test_comm, errhandler_type, error_handler, 1);
  77     GAP_CHECK("c_pml_comm", test_comm, c_pml_comm, errhandler_type, 1);
  78     GAP_CHECK("c_coll", test_comm, c_coll, c_pml_comm, 1);
  79 
  80     /* Test Predefined group sizes */
  81     printf("=============================================\n");
  82     printf("ompi_predefined_group_t = %lu bytes\n", sizeof(ompi_predefined_group_t));
  83     printf("ompi_group_t = %lu bytes\n", sizeof(ompi_group_t));
  84     GAP_CHECK("grp_proc_count", test_group, grp_proc_count, grp_proc_count, 0);
  85     GAP_CHECK("grp_my_rank", test_group, grp_my_rank, grp_proc_count, 1);
  86     GAP_CHECK("grp_f_to_c_index", test_group, grp_f_to_c_index, grp_my_rank, 1);
  87     GAP_CHECK("grp_proc_pointers", test_group, grp_proc_pointers, grp_f_to_c_index, 1);
  88     GAP_CHECK("grp_flags", test_group, grp_flags, grp_proc_pointers, 1);
  89     GAP_CHECK("grp_parent_group_ptr", test_group, grp_parent_group_ptr, grp_flags, 1);
  90 
  91     /* Test Predefined request sizes */
  92     printf("=============================================\n");
  93     printf("ompi_predefined_request_t = %lu bytes\n", sizeof(ompi_predefined_request_t));
  94     printf("ompi_request_t = %lu bytes\n", sizeof(ompi_request_t));
  95     GAP_CHECK("super", test_req, super, super, 0);
  96     GAP_CHECK("req_type", test_req, req_type, super, 1);
  97     GAP_CHECK("req_status", test_req, req_status, req_type, 1);
  98     GAP_CHECK("req_complete", test_req, req_complete, req_status, 1);
  99     GAP_CHECK("req_state", test_req, req_state, req_complete, 1);
 100     GAP_CHECK("req_persistent", test_req, req_persistent, req_state, 1);
 101     GAP_CHECK("req_f_to_c_index", test_req, req_f_to_c_index, req_persistent, 1);
 102     GAP_CHECK("req_free", test_req, req_free, req_f_to_c_index, 1);
 103 
 104     /* Test Predefined op sizes */
 105     printf("=============================================\n");
 106     printf("ompi_predefined_op_t = %lu bytes\n", sizeof(ompi_predefined_op_t));
 107     printf("ompi_op_t = %lu bytes\n", sizeof(ompi_op_t));
 108     GAP_CHECK("super", test_op, super, super, 0)
 109     GAP_CHECK("o_name", test_op, o_name, super, 1)
 110     GAP_CHECK("o_flags", test_op, o_flags, o_name, 1)
 111     GAP_CHECK("o_f_to_c_index", test_op, o_f_to_c_index, o_flags, 1)
 112     GAP_CHECK("o_func", test_op, o_func, o_f_to_c_index, 1)
 113     GAP_CHECK("o_3buff_instrinsic", test_op, o_3buff_intrinsic, o_func, 1)
 114 
 115     /* Test Predefined datatype sizes */
 116     printf("=============================================\n");
 117     printf("ompi_predefined_datatype_t = %lu bytes\n", sizeof(ompi_predefined_datatype_t));
 118     printf("ompi_datatype_t = %lu bytes\n", sizeof(ompi_datatype_t));
 119 
 120     /* Test Predefined win sizes */
 121     printf("=============================================\n");
 122     printf("ompi_predefined_win_t = %lu bytes\n", sizeof(ompi_predefined_win_t));
 123     printf("ompi_win_t = %lu bytes\n", sizeof(ompi_win_t));
 124     GAP_CHECK("super", test_win, super, super, 0);
 125     GAP_CHECK("w_lock", test_win, w_lock, super, 1);
 126     GAP_CHECK("w_name", test_win, w_name, w_lock, 1);
 127     GAP_CHECK("w_group", test_win, w_group, w_name, 1);
 128     GAP_CHECK("w_flags", test_win, w_flags, w_group, 1);
 129     GAP_CHECK("w_keyhash", test_win, w_keyhash, w_flags, 1);
 130     GAP_CHECK("w_f_to_c_index", test_win, w_f_to_c_index, w_keyhash, 1);
 131     GAP_CHECK("error_handler", test_win, error_handler, w_f_to_c_index, 1);
 132     GAP_CHECK("errhandler_type", test_win, errhandler_type, error_handler, 1);
 133     GAP_CHECK("w_osc_module", test_win, w_osc_module, errhandler_type, 1);
 134 
 135     /* Test Predefined info sizes */
 136     printf("=============================================\n");
 137     printf("ompi_predefined_info_t = %lu bytes\n", sizeof(ompi_predefined_info_t));
 138     printf("ompi_info_t = %lu bytes\n", sizeof(ompi_info_t));
 139     GAP_CHECK("super", test_info, super, super, 0);
 140     GAP_CHECK("i_f_to_c_index", test_info, i_f_to_c_index, super, 1);
 141     GAP_CHECK("i_freed", test_info, i_freed, i_f_to_c_index, 1);
 142 
 143     /* Test Predefined file sizes */
 144     printf("=============================================\n");
 145     printf("ompi_predefined_file_t = %lu bytes\n", sizeof(ompi_predefined_file_t));
 146     printf("ompi_file_t = %lu bytes\n", sizeof(ompi_file_t));
 147     GAP_CHECK("super", test_file, super, super, 0);
 148     GAP_CHECK("f_comm", test_file, f_comm, super, 1);
 149     GAP_CHECK("f_filename", test_file, f_filename, f_comm, 1);
 150     GAP_CHECK("f_amode", test_file, f_amode,  f_filename, 1);
 151     GAP_CHECK("f_flags", test_file, f_flags, f_amode,  1);
 152     GAP_CHECK("f_f_to_c_index", test_file, f_f_to_c_index, f_flags, 1);
 153     GAP_CHECK("error_handler", test_file, error_handler, f_f_to_c_index, 1);
 154     GAP_CHECK("errhandler_type", test_file, errhandler_type, error_handler, 1);
 155     GAP_CHECK("f_io_version", test_file, f_io_version, errhandler_type, 1);
 156     GAP_CHECK("f_io_selected_component", test_file, f_io_selected_component, f_io_version, 1);
 157     GAP_CHECK("f_io_selected_module", test_file, f_io_selected_module, f_io_selected_component, 1);
 158     GAP_CHECK("f_io_selected_data", test_file, f_io_selected_data, f_io_selected_module, 1);
 159 
 160     return 0;
 161 }

/* [<][>][^][v][top][bottom][index][help] */