Skip to content

Commit 6ed20b5

Browse files
authored
DPC++ Samples: setvars, VS Code, Diagnostics Utility (oneapi-src#855)
* DPC++ Sample Review Added consistent short description of setvars, VS Code and Diagnostics Utility. * DPC++ Samples review
1 parent 74219c4 commit 6ed20b5

File tree

26 files changed

+1217
-108
lines changed

26 files changed

+1217
-108
lines changed

DirectProgramming/DPC++/CombinationalLogic/mandelbrot/README.md

Lines changed: 116 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# `Mandelbrot` Sample
22

3-
Mandelbrot is an infinitely complex fractal patterning that is derived from a simple formula. It demonstrates using DPC++ for offloading computations to a GPU (or other devices) and shows how processing time can be optimized and improved with parallelism.
3+
Mandelbrot is an infinitely complex fractal patterning that is derived from a
4+
simple formula. It demonstrates using DPC++ for offloading computations to a
5+
GPU (or other devices) and shows how processing time can be optimized and
6+
improved with parallelism.
47

58
For comprehensive instructions see the [DPC++ Programming](https://software.intel.com/en-us/oneapi-programming-guide) and search based on relevant terms noted in the comments.
69

@@ -13,40 +16,132 @@ For comprehensive instructions see the [DPC++ Programming](https://software.inte
1316
| Time to complete | 15 minutes
1417

1518
## Purpose
16-
Mandelbrot is a DPC++ application that generates a fractal image by initializing a matrix of 512 x 512, where the computation at each point (pixel) is entirely independent of the computation at other points. The sample includes both parallel and serial calculation of the set, allowing for a direct comparison of results. The parallel implementation can demonstrate the use of Unified Shared Memory (USM) or buffers. You can modify parameters such as the number of rows, columns, and iterations to evaluate the difference in performance and load between USM and buffers. This is further described at the end of this document in the "Running the Sample" section.
1719

18-
The code will attempt to execute on an available GPU and fallback to the system's CPU if a compatible GPU is not detected. The compilation device is displayed in the output along with elapsed time to render the Mandelbrot image. This helps compare different offload implementations based on the complexity of the computation.
20+
Mandelbrot is a DPC++ application that generates a fractal image by
21+
initializing a matrix of 512 x 512, where the computation at each point (pixel)
22+
is entirely independent of the computation at other points. The sample includes
23+
both parallel and serial calculation of the set, allowing for a direct
24+
comparison of results. The parallel implementation can demonstrate the use of
25+
Unified Shared Memory (USM) or buffers. You can modify parameters such as the
26+
number of rows, columns, and iterations to evaluate the difference in
27+
performance and load between USM and buffers. This is further described at the
28+
end of this document in the "Running the Sample" section.
29+
30+
The code will attempt to execute on an available GPU and fallback to the
31+
system's CPU if a compatible GPU is not detected. The compilation device is
32+
displayed in the output along with elapsed time to render the Mandelbrot image.
33+
This helps compare different offload implementations based on the complexity of
34+
the computation.
1935

2036
## Key Implementation Details
21-
The basic DPC++ implementation explained in the code includes device selector, buffer, accessor, kernel, and command groups.
37+
38+
The basic DPC++ implementation explained in the code includes device selector,
39+
buffer, accessor, kernel, and command groups.
2240

2341
## License
2442
Code samples are licensed under the MIT license. See
2543
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
2644

2745
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)
2846

47+
48+
## Setting Environment Variables
49+
50+
51+
For working at a Command-Line Interface (CLI), the tools in the oneAPI toolkits
52+
are configured using environment variables. Set up your CLI environment by
53+
sourcing the ``setvars`` script every time you open a new terminal window. This
54+
will ensure that your compiler, libraries, and tools are ready for development.
55+
56+
57+
### Linux
58+
Source the script from the installation location, which is typically in one of
59+
these folders:
60+
61+
62+
For root or sudo installations:
63+
64+
65+
``. /opt/intel/oneapi/setvars.sh``
66+
67+
68+
For normal user installations:
69+
70+
``. ~/intel/oneapi/setvars.sh``
71+
72+
**Note:** If you are using a non-POSIX shell, such as csh, use the following command:
73+
74+
``$ bash -c 'source <install-dir>/setvars.sh ; exec csh'``
75+
76+
If environment variables are set correctly, you will see a confirmation
77+
message.
78+
79+
If you receive an error message, troubleshoot the problem using the
80+
Diagnostics Utility for Intel® oneAPI Toolkits, which provides system
81+
checks to find missing dependencies and permissions errors.
82+
[Learn more](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
83+
84+
85+
**Note:** [Modulefiles scripts](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-modulefiles-with-linux.html)
86+
can also be used to set up your development environment.
87+
The modulefiles scripts work with all Linux shells.
88+
89+
90+
**Note:** If you wish to fine
91+
tune the list of components and the version of those components, use
92+
a [setvars config file](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/use-a-config-file-for-setvars-sh-on-linux-or-macos.html)
93+
to set up your development environment.
94+
95+
### Windows
96+
97+
Execute the ``setvars.bat`` script from the root folder of your
98+
oneAPI installation, which is typically:
99+
100+
101+
``"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"``
102+
103+
104+
For Windows PowerShell* users, execute this command:
105+
106+
``cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'``
107+
108+
109+
If environment variables are set correctly, you will see a confirmation
110+
message.
111+
112+
If you receive an error message, troubleshoot the problem using the
113+
Diagnostics Utility for Intel® oneAPI Toolkits, which provides system
114+
checks to find missing dependencies and permissions errors.
115+
[Learn more](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
116+
29117
## Building the `Mandelbrot` Program for CPU and GPU
30118

31-
> Note: if you have not already done so, set up your CLI
32-
> environment by sourcing the setvars script located in
119+
120+
> **Note**: If you have not already done so, set up your CLI
121+
> environment by sourcing the `setvars` script located in
33122
> the root of your oneAPI installation.
34123
>
35124
> Linux Sudo: . /opt/intel/oneapi/setvars.sh
125+
>
36126
> Linux User: . ~/intel/oneapi/setvars.sh
127+
>
37128
> Windows: C:\Program Files(x86)\Intel\oneAPI\setvars.bat
129+
>
130+
>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).
131+
38132

39133
### Include Files
40134
The include folder is located at %ONEAPI_ROOT%\dev-utilities\latest\include on your development system.
41135

42136
### Running Samples In DevCloud
43-
Running samples in the Intel DevCloud requires you to specify a compute node. For specific instructions, jump to [Run the sample in the DevCloud](#run-on-devcloud)
137+
Running samples in the Intel DevCloud requires you to specify a compute node.
138+
For specific instructions, jump to [Run the sample in the DevCloud](#run-on-devcloud)
44139

45140

46141
### Using Visual Studio Code* (Optional)
47142

48-
You can use Visual Studio Code (VS Code) extensions to set your environment, create launch configurations,
49-
and browse and download samples.
143+
You can use Visual Studio Code (VS Code) extensions to set your environment,
144+
create launch configurations, and browse and download samples.
50145

51146
The basic steps to build and run a sample using VS Code include:
52147
- Download a sample using the extension **Code Sample Browser for Intel oneAPI Toolkits**.
@@ -55,11 +150,14 @@ The basic steps to build and run a sample using VS Code include:
55150
- Run the sample in the VS Code terminal using the instructions below.
56151

57152
To learn more about the extensions and how to configure the oneAPI environment, see
58-
[Using Visual Studio Code with Intel® oneAPI Toolkits](https://software.intel.com/content/www/us/en/develop/documentation/using-vs-code-with-intel-oneapi/top.html).
153+
[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).
154+
155+
After learning how to use the extensions for Intel oneAPI Toolkits, return to
156+
this readme for instructions on how to build and run a sample.
59157

60-
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.
61158

62159
### On a Linux* System
160+
63161
Perform the following steps:
64162
1. Build the program using the following `cmake` commands.
65163
```
@@ -84,6 +182,13 @@ $ make
84182
make clean
85183
```
86184
185+
If an error occurs, you can get more details by running `make` with the `VERBOSE=1` argument:
186+
``make VERBOSE=1``
187+
For more comprehensive troubleshooting, use the Diagnostics Utility for
188+
Intel® oneAPI Toolkits, which provides system checks to find missing dependencies and permissions errors.
189+
[Learn more](https://software.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
190+
191+
87192
### On a Windows* System Using Visual Studio* Version 2017 or Newer
88193
- Build the program using VS2017 or VS2019
89194
- Right-click on the solution file and open using either VS2017 or VS2019 IDE.

DirectProgramming/DPC++/CombinationalLogic/sepia-filter/README.md

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# `Sepia-filter` Sample
2-
The sepia filter is a program that converts a color image to a Sepia tone image, which is a monochromatic image with a distinctive Brown Gray color. The program works by offloading the compute intensive conversion of each pixel to Sepia tone and is implemented using DPC++ for CPU and GPU.
2+
3+
The sepia filter is a program that converts a color image to a Sepia tone
4+
image, which is a monochromatic image with a distinctive Brown Gray color. The
5+
program works by offloading the compute intensive conversion of each pixel to
6+
Sepia tone and is implemented using DPC++ for CPU and GPU.
37

48
For comprehensive instructions see the [DPC++ Programming](https://software.intel.com/en-us/oneapi-programming-guide) and search based on relevant terms noted in the comments.
59

@@ -12,27 +16,118 @@ For comprehensive instructions see the [DPC++ Programming](https://software.inte
1216
| Time to complete | 20 minutes
1317

1418
## Purpose
15-
The sepia filter is a DPC++ application that accepts a color image as an input and converts it to a sepia tone image by applying the sepia filter coefficients to every pixel of the image. The sample demonstrates offloading the compute intensive part of the application, which is the processing of individual pixels to an accelerator with lambda and functor kernels' help. The sample also demonstrates the usage of a custom device selector, which sets precedence for a GPU device over other available devices on the system.
16-
The device selected for offloading the kernel is displayed in the output and the time taken to execute each of the kernels. The application also outputs a sepia tone image of the input image.
19+
20+
The sepia filter is a DPC++ application that accepts a color image as an input
21+
and converts it to a sepia tone image by applying the sepia filter coefficients
22+
to every pixel of the image. The sample demonstrates offloading the compute
23+
intensive part of the application, which is the processing of individual pixels
24+
to an accelerator with lambda and functor kernels' help. The sample also
25+
demonstrates the usage of a custom device selector, which sets precedence for a
26+
GPU device over other available devices on the system. The device selected for
27+
offloading the kernel is displayed in the output and the time taken to execute
28+
each of the kernels. The application also outputs a sepia tone image of the
29+
input image.
1730

1831
## Key implementation details
19-
The basic DPC++ implementation explained in the code includes device selector, buffer, accessor, kernel, and command groups. This sample also demonstrates a custom device selector's implementation by overwriting the SYCL device selector class, offloading computation using both lambda and functor kernels, and using event objects to time command group execution, enabling profiling.
32+
33+
The basic DPC++ implementation explained in the code includes device selector,
34+
buffer, accessor, kernel, and command groups. This sample also demonstrates a
35+
custom device selector's implementation by overwriting the SYCL device selector
36+
class, offloading computation using both lambda and functor kernels, and using
37+
event objects to time command group execution, enabling profiling.
2038

2139
## License
2240
Code samples are licensed under the MIT license. See
2341
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
2442

2543
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)
2644

45+
46+
47+
## Setting Environment Variables
48+
49+
50+
For working at a Command-Line Interface (CLI), the tools in the oneAPI toolkits
51+
are configured using environment variables. Set up your CLI environment by
52+
sourcing the ``setvars`` script every time you open a new terminal window. This
53+
will ensure that your compiler, libraries, and tools are ready for development.
54+
55+
56+
### Linux
57+
Source the script from the installation location, which is typically in one of
58+
these folders:
59+
60+
61+
For root or sudo installations:
62+
63+
64+
``. /opt/intel/oneapi/setvars.sh``
65+
66+
67+
For normal user installations:
68+
69+
``. ~/intel/oneapi/setvars.sh``
70+
71+
**Note:** If you are using a non-POSIX shell, such as csh, use the following command:
72+
73+
``$ bash -c 'source <install-dir>/setvars.sh ; exec csh'``
74+
75+
If environment variables are set correctly, you will see a confirmation
76+
message.
77+
78+
If you receive an error message, troubleshoot the problem using the
79+
Diagnostics Utility for Intel® oneAPI Toolkits, which provides system
80+
checks to find missing dependencies and permissions errors.
81+
[Learn more](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
82+
83+
84+
**Note:** [Modulefiles scripts](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-modulefiles-with-linux.html)
85+
can also be used to set up your development environment.
86+
The modulefiles scripts work with all Linux shells.
87+
88+
89+
**Note:** If you wish to fine
90+
tune the list of components and the version of those components, use
91+
a [setvars config file](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/use-a-config-file-for-setvars-sh-on-linux-or-macos.html)
92+
to set up your development environment.
93+
94+
### Windows
95+
96+
Execute the ``setvars.bat`` script from the root folder of your
97+
oneAPI installation, which is typically:
98+
99+
100+
``"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"``
101+
102+
103+
For Windows PowerShell* users, execute this command:
104+
105+
``cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'``
106+
107+
108+
If environment variables are set correctly, you will see a confirmation
109+
message.
110+
111+
If you receive an error message, troubleshoot the problem using the
112+
Diagnostics Utility for Intel® oneAPI Toolkits, which provides system
113+
checks to find missing dependencies and permissions errors.
114+
[Learn more](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
115+
27116
## Building the Program for CPU and GPU
28117

29-
> Note: if you have not already done so, set up your CLI
30-
> environment by sourcing the setvars script located in
118+
119+
> **Note**: If you have not already done so, set up your CLI
120+
> environment by sourcing the `setvars` script located in
31121
> the root of your oneAPI installation.
32122
>
33123
> Linux Sudo: . /opt/intel/oneapi/setvars.sh
124+
>
34125
> Linux User: . ~/intel/oneapi/setvars.sh
126+
>
35127
> Windows: C:\Program Files(x86)\Intel\oneAPI\setvars.bat
128+
>
129+
>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).
130+
36131

37132
### Include Files
38133
The include folder is located at `%ONEAPI_ROOT%\dev-utilities\latest\include` on your development system.
@@ -77,6 +172,13 @@ Perform the following steps:
77172
78173
```
79174

175+
176+
If an error occurs, you can get more details by running `make` with the `VERBOSE=1` argument:
177+
``make VERBOSE=1``
178+
For more comprehensive troubleshooting, use the Diagnostics Utility for Intel® oneAPI Toolkits, which provides system checks to find missing dependencies and permissions errors.
179+
[Learn more](https://software.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html).
180+
181+
80182
### On a Windows* System Using Visual Studio* Version 2017 or Newer
81183
- Build the program using VS2017 or VS2019
82184
- Right-click on the solution file and open using either VS2017 or VS2019 IDE.

0 commit comments

Comments
 (0)