Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DataCommMode.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
20 /*
21  */
22 
29 #pragma once
30 
39  dataSplitFirst, // NOT USED
40  dataSplit // NOT USED
41 };
42 
47 
60 template <typename DataType>
61 DataCommMode get_data_mode(size_t num_selected, size_t num_total) {
62  DataCommMode data_mode = noData;
63  if (enforcedDataMode != noData) {
64  data_mode = enforcedDataMode;
65  } else { // no enforced mode, so find an appropriate mode
66  if (num_selected == 0) {
67  data_mode = noData;
68  } else if (num_selected == num_total) {
69  data_mode = onlyData;
70  } else {
71  size_t bitset_alloc_size =
72  ((num_total + 63) / 64) * sizeof(uint64_t) + (2 * sizeof(size_t));
73 
74  size_t bitsetDataSize = (num_selected * sizeof(DataType)) +
75  bitset_alloc_size + sizeof(num_selected);
76  size_t offsetsDataSize = (num_selected * sizeof(DataType)) +
77  (num_selected * sizeof(unsigned int)) +
78  sizeof(size_t) + sizeof(num_selected);
79  // find the minimum size one
80  if (bitsetDataSize < offsetsDataSize) {
81  data_mode = bitsetData;
82  } else {
83  data_mode = offsetsData;
84  }
85  }
86  }
87  return data_mode;
88 }
Definition: DataCommMode.h:35
DataCommMode get_data_mode(size_t num_selected, size_t num_total)
Given a size of a subset of elements to send and the total number of elements, determine an appropria...
Definition: DataCommMode.h:61
Definition: DataCommMode.h:37
send no data
Definition: DataCommMode.h:34
Definition: DataCommMode.h:38
Definition: DataCommMode.h:36
DataCommMode enforcedDataMode
Specifies what format to send metadata in.
Definition: GluonSubstrate.cpp:29
DataCommMode
Enumeration of data communication modes that can be used in synchronization.
Definition: DataCommMode.h:33
Definition: DataCommMode.h:39
Definition: DataCommMode.h:40