Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
print.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * thrill/api/print.hpp
3  *
4  * Part of Project Thrill - http://project-thrill.org
5  *
6  * Copyright (C) 2016 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the BSD-2 license in the LICENSE file.
9  ******************************************************************************/
10 
11 #pragma once
12 #ifndef THRILL_API_PRINT_HEADER
13 #define THRILL_API_PRINT_HEADER
14 
15 #include <thrill/api/gather.hpp>
16 
17 #include <string>
18 #include <vector>
19 
20 namespace thrill {
21 namespace api {
22 
23 template <typename ValueType, typename Stack>
24 void DIA<ValueType, Stack>::Print(const std::string& name, std::ostream& os) const {
25  assert(IsValid());
26 
28 
29  std::vector<ValueType> output;
30 
31  auto node = tlx::make_counting<GatherNode>(*this, "Print", 0, &output);
32 
33  node->RunScope();
34 
35  if (node->context().my_rank() == 0)
36  {
37  os << name
38  << " --- Begin DIA.Print() --- size=" << output.size() << '\n';
39  for (size_t i = 0; i < output.size(); ++i) {
40  os << name << '[' << i << "]: " << output[i] << '\n';
41  }
42  os << name
43  << " --- End DIA.Print() --- size=" << output.size() << std::endl;
44  }
45 }
46 
47 template <typename ValueType, typename Stack>
48 void DIA<ValueType, Stack>::Print(const std::string& name) const {
49  return Print(name, std::cout);
50 }
51 
52 } // namespace api
53 } // namespace thrill
54 
55 #endif // !THRILL_API_PRINT_HEADER
56 
57 /******************************************************************************/
void Print(const std::string &name) const
Print is an Action, which collects all data of the DIA at the worker 0 and prints using ostream seria...
Definition: print.hpp:48
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220