root/ompi/debuggers/predefined_pad_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  */
   9 
  10 /*
  11  * Simple test to print out how much space is left in the padding for
  12  * each of the predefined MPI object types.
  13  *
  14  * Warn if there is less than THRESHHOLD bytes of padding left; error
  15  * if there is no space left.
  16  */
  17 
  18 #include "ompi_config.h"
  19 
  20 #include <stdlib.h>
  21 
  22 #include "opal_stdint.h"
  23 
  24 #include "ompi/communicator/communicator.h"
  25 #include "ompi/group/group.h"
  26 #include "ompi/request/request.h"
  27 #include "ompi/op/op.h"
  28 #include "ompi/datatype/ompi_datatype.h"
  29 #include "ompi/win/win.h"
  30 #include "ompi/info/info.h"
  31 #include "ompi/file/file.h"
  32 #include "ompi/message/message.h"
  33 
  34 static int warnings = 0;
  35 static int errors = 0;
  36 
  37 #define THRESHHOLD 32
  38 
  39 
  40 #define PAD_CHECK(TYPE)                                                 \
  41     do {                                                                \
  42         size_t psize = sizeof(ompi_predefined_##TYPE##_t);              \
  43         size_t size = sizeof(ompi_##TYPE##_t);                          \
  44         size_t diff = psize - size;                                     \
  45         if (diff <= 0) {                                                \
  46             fprintf(stderr, "ERROR: Predefined " #TYPE " size: %" PRIsize_t ", " #TYPE " size: %" PRIsize_t " (%" PRIsize_t " bytes over)\n", psize, size, size - psize); \
  47         } else if (diff <= THRESHHOLD) {                                \
  48             fprintf(stderr, "WARNING: Predefined " #TYPE " has very little space left -- size : %" PRIsize_t ", " #TYPE " size: %" PRIsize_t " (%" PRIsize_t " bytes left)\n", psize, size, psize - size); \
  49         } else {                                                        \
  50             printf("Predefined " #TYPE " size : %" PRIsize_t ", " #TYPE " size: %" PRIsize_t " (%" PRIsize_t " bytes left)\n", psize, size, psize - size); \
  51         }                                                               \
  52     } while(0)
  53 
  54 int main(int argc, char **argv)
  55 {
  56     PAD_CHECK(communicator);
  57     PAD_CHECK(errhandler);
  58     PAD_CHECK(file);
  59     PAD_CHECK(win);
  60     PAD_CHECK(request);
  61     PAD_CHECK(info);
  62     PAD_CHECK(datatype);
  63     PAD_CHECK(group);
  64     PAD_CHECK(message);
  65     PAD_CHECK(op);
  66 
  67     if (warnings > 0) {
  68         fprintf(stderr, "NUMBER OF WARNINGS: %d\n", warnings);
  69     }
  70     if (errors > 0) {
  71         fprintf(stderr, "NUMBER OF ERRORS: %d\n", errors);
  72         exit(1);
  73     }
  74 
  75     return 0;
  76 }

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