Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LWCI.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 
27 #pragma once
28 #ifdef GALOIS_USE_LCI
29 #include "lc.h"
30 
31 extern lc_ep lc_col_ep;
32 extern lc_ep lc_p2p_ep[3];
33 
34 namespace galois {
35 namespace runtime {
36 namespace internal {
37 
47 template <typename Ty>
48 void ompi_op_sum(void* dst, void* src, size_t count) {
49  Ty* dst_ty = (Ty*)dst;
50  Ty* src_ty = (Ty*)src;
51  for (size_t i = 0; i < (count / sizeof(Ty)); ++i) {
52  dst_ty[i] += src_ty[i];
53  }
54 }
55 
65 template <typename Ty>
66 void ompi_op_max(void* dst, void* src, size_t count) {
67  Ty* dst_ty = (Ty*)dst;
68  Ty* src_ty = (Ty*)src;
69  for (size_t i = 0; i < (count / sizeof(Ty)); ++i) {
70  if (dst_ty[i] < src_ty[i]) {
71  dst_ty[i] = src_ty[i];
72  }
73  }
74 }
75 
85 template <typename Ty>
86 void ompi_op_min(void* dst, void* src, size_t count) {
87  Ty* dst_ty = (Ty*)dst;
88  Ty* src_ty = (Ty*)src;
89  for (size_t i = 0; i < (count / sizeof(Ty)); ++i) {
90  if (dst_ty[i] > src_ty[i]) {
91  dst_ty[i] = src_ty[i];
92  }
93  }
94 }
95 
96 } // namespace internal
97 } // namespace runtime
98 } // namespace galois
99 #endif