Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120843608
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
Mon, Jul 7, 11:34
Size
527 B
Mime Type
text/x-c
Expires
Wed, Jul 9, 11:34 (2 d)
Engine
blob
Format
Raw Data
Handle
27258698
Attached To
R11897 phys-743-lecture-codes
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