File: internode.cpp

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (35 lines) | stat: -rw-r--r-- 806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "InterNode.h"
#include "PsimagLite.h"

int main(int argc, char* argv[])
{
	PsimagLite::PsiApp psiApp("internode", &argc, &argv, 1);
	if (argc < 2) {
		std::cerr << "USAGE " << argv[0] << " number\n";
		return 1;
	}

	const SizeType n = atoi(argv[1]);

	// original
	for (SizeType i = 0; i < n; ++i) {
		std::cout << i;
	}

	std::cout << "\n--------------------------\n";

	// lambda
	PsimagLite::InterNode<> internode(PsimagLite::MPI::COMM_WORLD);

	internode.parallelFor(0, n, [](SizeType i, SizeType) { std::cout << i; });
	std::cout << "\n--------------------------\n";
	size_t len = 1024;
	char* name = new char[len + 1];
	int x = gethostname(name, len);
	if (x != 0)
		std::cerr << argv[0] << ": Could not gethostname\n";
	else
		std::cout << name << "\n";
	delete[] name;
	name = nullptr;
}