Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98662718
private.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 15, 10:05
Size
527 B
Mime Type
text/x-c
Expires
Fri, Jan 17, 10:05 (2 d)
Engine
blob
Format
Raw Data
Handle
23622756
Attached To
R11821 phys-743-lecture
private.cc
View Options
#include <iostream>
#include <omp.h>
int main() {
int a = 1, b = 2;
double c = 3.;
std::printf("Thread %i sees, a, b, c: %i, %i, %g (before)\n",
omp_get_thread_num(), a, b, c);
#pragma omp parallel num_threads(3), private(a), firstprivate(b)
{
std::printf("Thread %i sees, a, b, c: %i, %i, %g (inside)\n",
omp_get_thread_num(), a, b, c);
c = -1e-3;
}
std::printf("Thread %i sees, a, b, c: %i, %i, %g (after)\n",
omp_get_thread_num(), a, b, c);
return 0;
}
Event Timeline
Log In to Comment