Difference between revisions of "GPU621/Distributed Workload"

From CDOT Wiki
Jump to: navigation, search
(Overview)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
'''TBB''': <br />
+
==== TBB ====
 
Is a template library developed by Intel to provide methods to facilitate parallel programming.  This is done by dividing a computation into tasks that can be scheduled to run in parallel threads on multi-core processors <br />
 
Is a template library developed by Intel to provide methods to facilitate parallel programming.  This is done by dividing a computation into tasks that can be scheduled to run in parallel threads on multi-core processors <br />
 
Threading Building Blocks includes algorithms, concurrent containers, locks and memory allocation tools. <br />
 
Threading Building Blocks includes algorithms, concurrent containers, locks and memory allocation tools. <br />
 
TBB is designed to work with any C++ compiler. <br />
 
TBB is designed to work with any C++ compiler. <br />
'''STL''': <br />
+
<pre>
 +
#include <tbb/tbb.h>
 +
 
 +
blocked_range<int> range0(0 ,40);
 +
for (auto i = range.begin(); i != range.end(); i++) {
 +
b[i] = 2 * a[i] + b[i];
 +
}
 +
</pre>
 +
==== STL ====
 
The Standard Template Library also extends useful functionality, including generic data structures, containers, iterators and algorithms that can be used to write clean efficient code. <br />
 
The Standard Template Library also extends useful functionality, including generic data structures, containers, iterators and algorithms that can be used to write clean efficient code. <br />
 
The person who in 1979 was initially interested with ideas of generic programming, his work at AT&T and Bell Laboratories eventually lead to a proposal to the ANSI/ISO for the standardization of STL into the C++ standard.  
 
The person who in 1979 was initially interested with ideas of generic programming, his work at AT&T and Bell Laboratories eventually lead to a proposal to the ANSI/ISO for the standardization of STL into the C++ standard.  
[[File:Parallel_for.PNG|344px|thumb|left|TBB parallel_for]]
+
<pre>
[[File:Vector_iter.PNG|500px|thumb|right|STL Vector and Iterators]]
+
#include <iostream>
 +
#include <vector>
 +
int main () {
 +
  std::vector<int> myvector;
 +
  for (int i=0; i < 6; i++) myvector.push_back(i);
 +
 
 +
  for (std::vector<int>::iterator it = myvector.begin(); it != myvector.end(); ++it)
 +
    std::cout << ' ' << *it;
 +
  std::cout << '/n';
 +
}
 +
 
 +
== Comparison ==
 +
Both libraries use C++ templates

Revision as of 00:45, 3 December 2018

Overview

TBB

Is a template library developed by Intel to provide methods to facilitate parallel programming. This is done by dividing a computation into tasks that can be scheduled to run in parallel threads on multi-core processors
Threading Building Blocks includes algorithms, concurrent containers, locks and memory allocation tools.
TBB is designed to work with any C++ compiler.

#include <tbb/tbb.h>

blocked_range<int> range0(0 ,40);
for (auto i = range.begin(); i != range.end(); i++) {
	 b[i] = 2 * a[i] + b[i];
}

STL

The Standard Template Library also extends useful functionality, including generic data structures, containers, iterators and algorithms that can be used to write clean efficient code.
The person who in 1979 was initially interested with ideas of generic programming, his work at AT&T and Bell Laboratories eventually lead to a proposal to the ANSI/ISO for the standardization of STL into the C++ standard.

#include <iostream>
#include <vector>
int main () {
  std::vector<int> myvector;
  for (int i=0; i < 6; i++) myvector.push_back(i);

  for (std::vector<int>::iterator it = myvector.begin(); it != myvector.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '/n';
}

Comparison

Both libraries use C++ templates