Home > Back-end >  Compile and run the OpenMP program
Compile and run the OpenMP program

Time:04-15

Experiment 2-1.? Compile and run the OpenMP program?
1.? The experiment purpose?
1)? On a Linux platform to compile and run the OpenMP program; ?
2)? On Windows platforms to compile and run the OpenMP program,?
3)? Mastered the basic OpenMP parallel programming,?
2.? The experimental environment?
1)? A hardware environment: computer; ?
2)? Software environment: Linux, Win2003, GCC, MPICH, VS2008 or other Visual? Studio; ?
?
3.? The experiment content?
1.? Under Linux OpenMP program to compile and run, OpenMP is a Shared memory parallel system application programming to meet
Mouth, support for C/C + + and FORTRAN language, compile and run a simple "Hello? World "program, under Linux editor
Hellomp. C source program, or under the Windows editor and through the attached upload FTP tool (port number: 1021),
With "GCC? - fopenmp? - O2? - o? Hellomp. Out? Hellomp. C "commands to compile and use"./hellomp out "command to run the program,?
Note: when using the vi editor in the virtual machine file, not in ESC exit insert mode, you can use "Ctrl + c" into the
In command mode, then enter to save wq,?
The code is as follows:?
?
# include? ?
# include? ?
Int? The main ()?
{?
Int? Nthreads, dar. ?
Omp_set_num_threads (8); ?
# pragma? Omp? The parallel? Private (nthreads, tid)?
{?
Tid=omp_get_thread_num (); ?
Printf (" Hello? World? from? OMP? The thread? % d \ n ", tid); ?
If (tid==0)?
{?
Nthreads=omp_get_num_threads (); ?
Printf (" Number? Of? Threads? is? % d \ n ", nthreads); ?
}?
}?
}?
?
?
  • Related