Open main menu

CDOT Wiki β

Changes

OpenMP Debugging in Visual Studio / Team Debug

3,146 bytes added, 16:04, 5 December 2017
Case B
Using the Parallel Stacks window
 
 
 
// cilk threads
#include <iostream>
#include <cilk/cilk.h>
#include <cilk/cilk_api.h>
#include <thread> // std::this_thread::sleep_for
#include <chrono> // std::chrono::seconds
void foo();
void boo();
void coo();
void doo();
void zoo();
void bla();
void blo();
void blu();
void vroom();
void beep();
void screech();
void woof();
void meow();
void oink();
void zzz();
void cough();
int main() {
int i = 12;
int nwt = __cilkrts_get_nworkers();
std::cout << "Number of workers is " << nwt << std::endl;
int a = 1;
cilk_spawn foo();
cilk_spawn coo();
cilk_spawn boo();
cilk_spawn doo();
cilk_spawn zoo();
foo();
cilk_sync;
#pragma cilk grainsize = 3
cilk_for(int i = 0; i < 10; i++) {
bla();
}
return 0;
}
void foo() {
int tid = __cilkrts_get_worker_number();
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("Foo! from worker %d\n", tid);
return;
}
void boo() {
int tid = __cilkrts_get_worker_number();
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("Boo! from worker %d\n", tid);
zzz();
return;
}
void coo() {
int tid = __cilkrts_get_worker_number();
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("Coo! from worker %d\n", tid);
bla();
return;
}
void doo() {
int tid = __cilkrts_get_worker_number();
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("Doo! from worker %d\n", tid);
vroom();
return;
}
void zoo() {
int tid = __cilkrts_get_worker_number();
std::this_thread::sleep_for(std::chrono::seconds(1));
printf("Zoo! from worker %d\n", tid);
woof();
meow();
oink();
return;
}
void bla() {
int tid = __cilkrts_get_worker_number();
printf("Bla bla! from worker %d\n", tid);
blo();
return;
}
void blo() {
int tid = __cilkrts_get_worker_number();
printf("Blo Blo! from worker %d\n", tid);
blu();
return;
}
void blu() {
int tid = __cilkrts_get_worker_number();
printf("Blu Blu! from worker %d\n", tid);
return;
}
void vroom() {
int tid = __cilkrts_get_worker_number();
printf("Vroom! from worker %d\n", tid);
beep();
return;
}
void beep() {
int tid = __cilkrts_get_worker_number();
printf("Beep beep! from worker %d\n", tid);
screech();
return;
}
void screech() {
int tid = __cilkrts_get_worker_number();
printf("Screeeeeeeeechhhhhh! from worker %d\n", tid);
return;
}
void woof() {
int tid = __cilkrts_get_worker_number();
printf("Woof! from worker %d\n", tid);
return;
}
void meow() {
int tid = __cilkrts_get_worker_number();
printf("Meow! from worker %d\n", tid);
return;
}
void oink() {
int tid = __cilkrts_get_worker_number();
printf("Oink! from worker %d\n", tid);
return;
}
void zzz() {
int tid = __cilkrts_get_worker_number();
for (int i = 0; i < 10; i++) {
cough();
}
printf("Zzzzzzzzz...... from worker %d\n", tid);
return;
}
void cough() {
int tid = __cilkrts_get_worker_number();
printf("cough! from worker %d\n", tid);
return;
}
==Case C==
92
edits