Tutorial by Examples: alle

void parallelAddition (unsigned N, const double *A, const double *B, double *C) { unsigned i; #pragma omp parallel for shared (A,B,C,N) private(i) schedule(static) for (i = 0; i < N; ++i) { C[i] = A[i] + B[i]; } } This example adds two vector (A and B into...
#include <omp.h> #include <stdio.h> int main (void) { int t = (0 == 0); // true value int f = (1 == 0); // false value #pragma omp parallel if (f) { printf ("FALSE: I am thread %d\n", omp_get_thread_num()); } #pragma omp parallel if (t) { printf (&quo...
#include <omp.h> #include <unistd.h> #include <iostream> #include <list> static void processElement (unsigned n) { // Tell who am I. The #pragma omp critical ensures that // only one thread sends data to std::cout #pragma omp critical std::cout <...
index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *"/> ...
To find the largest items in a collection, heapq module has a function called nlargest, we pass it two arguments, the first one is the number of items that we want to retrieve, the second one is the collection name: import heapq numbers = [1, 4, 2, 100, 20, 50, 32, 200, 150, 8] print(heapq.nl...
The most interesting property of a heap is that its smallest element is always the first element: heap[0] import heapq numbers = [10, 4, 2, 100, 20, 50, 32, 200, 150, 8] heapq.heapify(numbers) print(numbers) # Output: [2, 4, 10, 100, 8, 50, 32, 200, 150, 20] heapq.heappop(numbers) # 2...
crawled_site = ["http://www.google.com", "http://www.stackoverflow.com"] |> Enum.map(fn site -> Task.async(fn -> crawl(site) end) end) |> Enum.map(&Task.await/1)
The Data.Functor module contains two combinators, <$ and $>, which ignore all of the values contained in a functor, replacing them all with a single constant value. infixl 4 <$, $> <$ :: Functor f => a -> f b -> f a (<$) = fmap . const $> :: Functor f => f a ...
Parallel extensions have been introduced along with the Task Parallel Library to achieve data Parallelism. Data parallelism refers to scenarios in which the same operation is performed concurrently (that is, in parallel) on elements in a source collection or array. The .NET provides new constructs t...
Probably the easies way to set up ruby on windows is to go to http://rubyinstaller.org/ and from there donwload an executable that you will install. You don't have to set almost anything, but there will be one important window. It will have a check box saying Add ruby executable to your PATH. Confi...
This example illustrates the basics of executing sections of code in parallel. As OpenMP is a built-in compiler feature, it works on any supported compilers without including any libraries. You may wish to include omp.h if you want to use any of the openMP API features. Sample Code std::cout <...
This example shows how to execute chunks of code in parallel std::cout << "begin "; // Start of parallel sections #pragma omp parallel sections { // Execute these sections in parallel #pragma omp section { ... do something ... std::cout <...
This example shows how to divide a loop into equal parts and execute them in parallel. // Splits element vector into element.size() / Thread Qty // and allocate that range for each thread. #pragma omp parallel for for (size_t i = 0; i < element.size(); ++i) element[i] = ... /...
This example illustrates a concept to perform reduction or gathering using std::vector and OpenMP. Supposed we have a scenario where we want multiple threads to help us generate a bunch of stuff, int is used here for simplicity and can be replaced with other data types. This is particularly useful...
map() is a built-in function, which means that it is available everywhere without the need to use an 'import' statement. It is available everywhere just like print() If you look at Example 5 you will see that I had to use an import statement before I could use pretty print (import pprint). Thus ppr...
workflow DoSomeWork { parallel { Get-Process -ComputerName server01 Get-Process -ComputerName server02 Get-Process -ComputerName server03 } } One of the unique features of PowerShell Workflow is the ability to define a block of activities as parallel. To use this feature, us...
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectActivityLeaks() .detectLeakedClosableObjects() .penaltyLog() .build());
Coding method used: Hybrid/Spongy It has been forever a myth that div's can not be used in emails. There are email clients (unlike outlook) that can render div's properly. The example below will illustrate how an email can be coded that will work on Gmail app (with updates not rolled out yet), Sams...
A very common use-case in web applications is performing multiple asynchronous (eg. HTTP) requests and gathering their results as they arrive or all of them at once (eg. in Angular2 with the HTTP service). 1. Gathering async responses one by one as they arrive This is typically done with mergeMap(...
In kafka, each consumer from the same consumer group gets assigned one or more partitions. Note that it is not possible for two consumers to consume from the same partition. The number of flink consumers depends on the flink parallelism (defaults to 1). There are three possible cases: kafka pa...

Page 6 of 7