Skip to content

Commit 9c7d508

Browse files
authored
Fortran and Libraries Readme (oneapi-src#859)
For each README file in the Fortran and Libraries folders, I changed or added consistent text for: - using VS Code - setvars - Diagnostics Utility.
1 parent e2074f2 commit 9c7d508

File tree

31 files changed

+878
-294
lines changed

31 files changed

+878
-294
lines changed
Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,91 @@
11
# `OpenMP Primes` Samples
2-
This sample is designed to illustrate how to use
2+
This sample is designed to illustrate how to use
33
the OpenMP* API with the Intel® Fortran Compiler.
44

5-
This program finds all primes in the first 40,000,000 integers,
6-
the number of 4n+1 primes, and the number of 4n-1 primes in the same range.
5+
This program finds all primes in the first 40,000,000 integers,
6+
the number of 4n+1 primes, and the number of 4n-1 primes in the same range.
77
It illustrates two OpenMP* directives to help speed up the code.
88

9-
9+
1010
| Optimized for | Description
1111
|:--- |:---
12-
| OS | macOS* with Xcode* installed
12+
| OS | macOS* with Xcode* installed
1313
| Software | Intel® Fortran Compiler
1414
| What you will learn | How to build and run a Fortran OpenMP application using Intel Fortran Compiler
1515
| Time to complete | 10 minutes
1616

1717
## Purpose
1818

19-
This program finds all primes in the first 40,000,000 integers, the number of 4n+1 primes,
20-
and the number of 4n-1 primes in the same range. It illustrates two OpenMP* directives
19+
This program finds all primes in the first 40,000,000 integers, the number of 4n+1 primes,
20+
and the number of 4n-1 primes in the same range. It illustrates two OpenMP* directives
2121
to help speed up the code.
2222

23-
First, a dynamic schedule clause is used with the OpenMP* for a directive.
24-
Because the DO loop's workload increases as its index get bigger,
25-
the default static scheduling does not work well. Instead, dynamic scheduling
26-
is used to account for the increased workload.
27-
But dynamic scheduling itself has more overhead than static scheduling,
23+
First, a dynamic schedule clause is used with the OpenMP* for a directive.
24+
Because the DO loop's workload increases as its index get bigger,
25+
the default static scheduling does not work well. Instead, dynamic scheduling
26+
is used to account for the increased workload.
27+
But dynamic scheduling itself has more overhead than static scheduling,
2828
so a chunk size of 10 is used to reduce the overhead for dynamic scheduling.
2929

30-
Second, a reduction clause is used instead of an OpenMP* critical directive
31-
to eliminate lock overhead. A critical directive would cause excessive lock overhead
32-
due to the one-thread-at-time update of the shared variables each time through the DO loop.
30+
Second, a reduction clause is used instead of an OpenMP* critical directive
31+
to eliminate lock overhead. A critical directive would cause excessive lock overhead
32+
due to the one-thread-at-time update of the shared variables each time through the DO loop.
3333
Instead, the reduction clause causes only one update of the shared variables once at the end of the loop.
3434

35-
The sample can be compiled unoptimized (-O0 ), or at any level of
35+
The sample can be compiled unoptimized (-O0 ), or at any level of
3636
optimization (-O1 through -O3 ). Also, the following compiler options are needed.
3737

38-
The option -qopenmp enables compiler recognition of OpenMP* directives.
38+
The option -qopenmp enables compiler recognition of OpenMP* directives.
3939
This option can also be omitted, in which case the generated executable will be a serial program.
4040

4141
The option -fpp enables the Fortran preprocessor.
4242
Read the Intel® Fortran Compiler Documentation for more information about these options.
4343

4444
## Key Implementation Details
45-
The Intel® oneAPI Intel Fortran Compiler includes all libraries and headers necessary to compile and run OpenMP* enabled Fortran applications. Users simply use the -qopenmp compiler option to compile and link their OpenMP enabled applications.
45+
The Intel® oneAPI Intel Fortran Compiler includes all libraries and headers necessary to compile and run OpenMP* enabled Fortran applications. Users simply use the -qopenmp compiler option to compile and link their OpenMP enabled applications.
4646

47-
## License
47+
## License
4848
Code samples are licensed under the MIT license. See
4949
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
5050

5151
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt)
5252

53-
## Building the `Fortran OpenMP*` sample
53+
## Using Visual Studio Code* (Optional)
54+
55+
You can use Visual Studio Code (VS Code) extensions to set your environment, create launch configurations,
56+
and browse and download samples.
57+
58+
The basic steps to build and run a sample using VS Code include:
59+
- Download a sample using the extension **Code Sample Browser for Intel oneAPI Toolkits**.
60+
- Configure the oneAPI environment with the extension **Environment Configurator for Intel oneAPI Toolkits**.
61+
- Open a Terminal in VS Code (**Terminal>New Terminal**).
62+
- Run the sample in the VS Code terminal using the instructions below.
63+
- (Linux only) Debug your GPU application with GDB for Intel® oneAPI toolkits using the **Generate Launch Configurations** extension.
64+
65+
To learn more about the extensions, see
66+
[Using Visual Studio Code with Intel® oneAPI Toolkits](https://www.intel.com/content/www/us/en/develop/documentation/using-vs-code-with-intel-oneapi/top.html).
67+
68+
After learning how to use the extensions for Intel oneAPI Toolkits, return to this readme for instructions on how to build and run a sample.
69+
70+
## Building the `Fortran OpenMP*` sample
71+
72+
> **Note**: If you have not already done so, set up your CLI
73+
> environment by sourcing the `setvars` script located in
74+
> the root of your oneAPI installation.
75+
>
76+
> Linux Sudo: . /opt/intel/oneapi/setvars.sh
77+
>
78+
> Linux User: . ~/intel/oneapi/setvars.sh
79+
>
80+
> Windows: C:\Program Files(x86)\Intel\oneAPI\setvars.bat
81+
>
82+
>For more information on environment variables, see Use the setvars Script for [Linux or macOS](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-the-setvars-script-with-linux-or-macos.html), or [Windows](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-the-setvars-script-with-windows.html).
5483
5584
### Experiment 1: Unoptimized build and run
5685
* Build openmp_samples
5786

58-
cd openmp_samples
59-
make clean
87+
cd openmp_samples
88+
make clean
6089
make debug
6190

6291
* Run the program
@@ -65,16 +94,16 @@ Third party program Licenses can be found here: [third-party-programs.txt](https
6594

6695
* What did you see?
6796

68-
Did the debug, unoptimized code run slower?
69-
70-
### Experiment 2: Default Optimized build and run
97+
Did the debug, unoptimized code run slower?
98+
99+
### Experiment 2: Default Optimized build and run
71100

72101
* Build openmp_samples
73102

74-
make
103+
make
75104
* Run the program
76105

77-
make run
106+
make run
78107

79108
### Experiment 3: Controlling the number of threads
80109
By default, an OpenMP application creates and uses as many threads as the number of "processors" in a system. A "processor" is defined as the number of logical processors, which are twice the number of physical cores on hyperthreaded cores.
@@ -89,13 +118,18 @@ note the number of threads reported by the application. Now try two threads:
89118
make run
90119
Did the make the application run faster? Experiment with the number of threads and see how it affects performance.
91120

92-
### Clean up
93-
* Clean the program
121+
### Clean up
122+
* Clean the program
94123
make clean
95124

125+
### Troubleshooting
126+
If an error occurs, troubleshoot the problem using the Diagnostics Utility for Intel® oneAPI Toolkits.
127+
[Learn more](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html)
128+
129+
96130
## Further Reading
97-
Interested in learning more? We have a wealth of information
98-
on using OpenMP with the Intel Fortran Compiler in our
131+
Interested in learning more? We have a wealth of information
132+
on using OpenMP with the Intel Fortran Compiler in our
99133
[OpenMP section of Developer Guide and Reference][1]
100134

101135
[1]: https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-developer-guide-and-reference/top/optimization-and-programming-guide/openmp-support.html "Developer Guide and Reference"

0 commit comments

Comments
 (0)