Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions AI-and-Analytics/Getting-Started-Samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Third party program Licenses can be found here: [third-party-programs.txt](https

# Getting Started Samples

|AI Tools preset bundle | Compoment | Folder | Description
|AI Tools preset | Component | Folder | Description
|--------------------------| --------- | ------------------------------------------------ | -
|Deep Learning| Intel® Neural Compressor | [INC-Sample-for-PyTorch](INC-Quantization-Sample-for-PyTorch) | Performs INT8 quantization on a Hugging Face BERT model.
|Deep Learning| Intel® Neural Compressor | [INC-Sample-for-Tensorflow](INC-Sample-for-Tensorflow) | Quantizes a FP32 model into INT8 by Intel® Neural Compressor and compares the performance between FP32 and INT8.
|Deep Learning | oneAPI docker image | [IntelAIKitContainer_GettingStarted](IntelAIKitContainer_GettingStarted) | Configuration script to automatically configure the environment.
|Data Analytics | Modin | [IntelModin_GettingStarted](IntelModin_GettingStarted) | Run Modin-accelerated Pandas functions and note the performance gain.
|Data Analytics | Modin |[IntelModin_Vs_Pandas](IntelModin_Vs_Pandas)| Compares the performance of Intel® Distribution of Modin* and the performance of Pandas.
|Inference Optimization| Intel® Neural Compressor | [INC-Sample-for-PyTorch](INC-Quantization-Sample-for-PyTorch) | Performs INT8 quantization on a Hugging Face BERT model.
|Inference Optimization| Intel® Neural Compressor | [INC-Sample-for-Tensorflow](INC-Sample-for-Tensorflow) | Quantizes a FP32 model into INT8 by Intel® Neural Compressor and compares the performance between FP32 and INT8.
|Data Analytics <br/> Classical Machine Learning <br/> Deep Learning <br/> Inference Optimization | oneAPI docker image | [IntelAIKitContainer_GettingStarted](IntelAIKitContainer_GettingStarted) | Configuration script to automatically configure the environment.
|Data Analytics <br/> Classical Machine Learning | Modin | [IntelModin_GettingStarted](IntelModin_GettingStarted) | Run Modin-accelerated Pandas functions and note the performance gain.
|Data Analytics <br/> Classical Machine Learning | Modin |[IntelModin_Vs_Pandas](IntelModin_Vs_Pandas)| Compares the performance of Intel® Distribution of Modin* and the performance of Pandas.
|Classical Machine Learning| Intel® Optimization for XGBoost* | [IntelPython_XGBoost_GettingStarted](IntelPython_XGBoost_GettingStarted) | Set up and trains an XGBoost* model on datasets for prediction.
|Classical Machine Learning| daal4py | [IntelPython_daal4py_GettingStarted](IntelPython_daal4py_GettingStarted) | Batch linear regression using the Python API package daal4py from oneAPI Data Analytics Library (oneDAL).
|Deep Learning| Intel® Optimization for TensorFlow* | [IntelTensorFlow_GettingStarted](IntelTensorFlow_GettingStarted) | A simple training example for TensorFlow.
|Deep Learning|Intel® Extension of PyTorch | [IntelPyTorch_GettingStarted](Intel_Extension_For_PyTorch_GettingStarted) | A simple training example for Intel® Extension of PyTorch.
|Deep Learning <br/> Inference Optimization| Intel® Optimization for TensorFlow* | [IntelTensorFlow_GettingStarted](IntelTensorFlow_GettingStarted) | A simple training example for TensorFlow.
|Deep Learning <br/> Inference Optimization |Intel® Extension of PyTorch | [IntelPyTorch_GettingStarted](Intel_Extension_For_PyTorch_GettingStarted) | A simple training example for Intel® Extension of PyTorch.
|Classical Machine Learning| Scikit-learn (OneDAL) | [Intel_Extension_For_SKLearn_GettingStarted](Intel_Extension_For_SKLearn_GettingStarted) | Speed up a scikit-learn application using Intel oneDAL.
|Deep Learning|Intel® Extension of TensorFlow | [Intel® Extension For TensorFlow GettingStarted](Intel_Extension_For_TensorFlow_GettingStarted) | Guides users how to run a TensorFlow inference workload on both GPU and CPU.
|Deep Learning|oneCCL Bindings for PyTorch | [Intel oneCCL Bindings For PyTorch GettingStarted](Intel_oneCCL_Bindings_For_PyTorch_GettingStarted) | Guides users through the process of running a simple PyTorch* distributed workload on both GPU and CPU. |
|Deep Learning <br/> Inference Optimization |Intel® Extension of TensorFlow | [Intel® Extension For TensorFlow GettingStarted](Intel_Extension_For_TensorFlow_GettingStarted) | Guides users how to run a TensorFlow inference workload on both GPU and CPU.
|Deep Learning <br/> Inference Optimization |oneCCL Bindings for PyTorch | [Intel oneCCL Bindings For PyTorch GettingStarted](Intel_oneCCL_Bindings_For_PyTorch_GettingStarted) | Guides users through the process of running a simple PyTorch* distributed workload on both GPU and CPU. |

*Other names and brands may be claimed as the property of others. [Trademarks](https://www.intel.com/content/www/us/en/legal/trademarks.html)
160 changes: 18 additions & 142 deletions DirectProgramming/C++SYCL/CombinationalLogic/mandelbrot/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
# `Mandelbrot` Sample

Mandelbrot is an infinitely complex fractal pattern that is derived from a
simple formula. This `Mandelbrot` sample demonstrates how to use SYCL*-compliant code for offloading computations to a GPU (or other devices) and further demonstrates how to optimize and improve processing time using parallelism.
Mandelbrot is an infinitely complex fractal pattern that is derived from a simple formula. This `Mandelbrot` sample demonstrates how to use SYCL*-compliant code for offloading computations to a GPU (or other devices) and further demonstrates how to optimize and improve processing time using parallelism.

| Property | Description
|:--- |:---
| What you will learn | How to offload the computation to GPU using the Intel&reg; oneAPI DPC++/C++ Compiler
| Time to complete | 15 minutes
|:--- |:---
| What you will learn | How to offload the computation to GPU using the Intel&reg; oneAPI DPC++/C++ Compiler
| Time to complete | 15 minutes

For comprehensive information in oneAPI programming, see the [Intel&reg; oneAPI Programming Guide](https://software.intel.com/en-us/oneapi-programming-guide). (Use search or the table of contents to find relevant information.)

## Purpose

This `Mandelbrot` sample is a SYCL-compliant 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 calculations of the set, which allows for direct results comparison. The parallel implementation demonstrates 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 `Mandelbrot` sample is a SYCL-compliant 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 calculations of the set, which allows for direct results comparison. The parallel implementation demonstrates 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.

## Prerequisites
| Property | Description
|:--- |:---
| OS | Ubuntu* 18.04 <br>Windows* 10
| Hardware | Skylake with GEN9 or newer
| Software | Intel&reg; oneAPI DPC++/C++ Compiler
|:--- |:---
| OS | Ubuntu* 18.04 <br>Windows* 10
| Hardware | Skylake with GEN9 or newer
| Software | Intel&reg; oneAPI DPC++/C++ Compiler

## Key Implementation Details

The program attempts first to run on an available GPU, and it will fall back to the system CPU if it does not detect a compatible GPU.

The program output displays the compilation device and elapsed render time for the Mandelbrot image, which helps compare different offload implementations based on the complexity of the computation.

The basic SYCL implementation explained in the code includes device selector,
buffer, accessor, kernel, and command groups.
The basic SYCL implementation explained in the code includes device selector, buffer, accessor, kernel, and command groups.

## Build the `Mandelbrot` Sample

### Setting Environment Variables
For working with the Command-Line Interface (CLI), you should configure the oneAPI toolkits using environment variables. Set up your CLI environment by
sourcing the `setvars` script every time you open a new terminal window. This practice ensures your compiler, libraries, and tools are ready for development.
When working with the Command Line Interface (CLI), you should configure the oneAPI toolkits using environment variables. Set up your CLI environment by sourcing the `setvars` script every time you open a new terminal window. This practice ensures your compiler, libraries, and tools are ready for development.

> **Note**: If you have not already done so, set up your CLI
> environment by sourcing the `setvars` script located in
> the root of your oneAPI installation.
> **Note**: If you have not already done so, set up your CLI environment by sourcing the `setvars` script located in the root of your oneAPI installation.
>
> Linux*:
> - For system wide installations: `. /opt/intel/oneapi/setvars.sh`
Expand All @@ -56,19 +45,18 @@ sourcing the `setvars` script every time you open a new terminal window. This pr
> - `C:\Program Files(x86)\Intel\oneAPI\setvars.bat`
> - For Windows PowerShell*, use the following command: `cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'`
>
> Microsoft Visual Studio:
> - Open a command prompt window and execute `setx SETVARS_CONFIG " "`. This only needs to be set once and will automatically execute the `setvars` script every time Visual Studio is launched.
>
>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).

You can use [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) to set up your development environment. The modulefiles scripts work with all Linux shells.

If you wish to fine tune the list of components and the version of those components, use
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) to set up your development environment.

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

### Using Visual Studio Code* (Optional)
You can use Visual Studio Code* (VS Code) extensions to set your environment,
create launch configurations, and browse and download samples.
You can use Visual Studio Code* (VS Code) extensions to set your environment, create launch configurations, and browse and download samples.

The basic steps to build and run a sample using VS Code include:
- Download a sample using the extension **Code Sample Browser for Intel&reg; oneAPI Toolkits**.
Expand Down Expand Up @@ -149,120 +137,8 @@ Rendered image output to file: mandelbrot.png (output too large to display in te
Successfully computed Mandelbrot set.
```

## Build the `Mandelbrot` Sample in Intel&reg; DevCloud
If running a sample in the Intel&reg; DevCloud, you must specify the compute node (CPU, GPU, FPGA) and whether to run in batch or interactive mode. For more information, see the Intel&reg; oneAPI Base Toolkit [Get Started Guide](https://devcloud.intel.com/oneapi/get_started/).

1. Open a terminal on a Linux system.

2. Log in to the Intel&reg; DevCloud.
```
ssh devcloud
```

3. Download the samples from GitHub.
```
git clone https://github.com/oneapi-src/oneAPI-samples.git
```

4. Change directories to the sample directory.
```
cd ~/oneAPI-samples/DirectProgramming/DPC++/CombinationalLogic/mandelbrot
```

### Build and Run the Sample in Batch Mode (optional)
The following instruction describe the optional process of submitting build and run jobs
in a Portable Bash Script (PBS). A job is a script that is submitted to PBS through the qsub utility. By default, the qsub utility does not inherit the current environment variables or your current working directory. For this reason, it is necessary to submit jobs as scripts that handle the setup of the environment variables. In order to address the working directory issue, you can either use absolute paths or pass the `-d \<dir\>` option to qsub to set the working directory.

### Create the Job Scripts

1. Create a **build.sh** script in a text editor.
```
nano build.sh
```

2. Add the following text to the **build.sh** file.
```
source /opt/intel/inteloneapi/setvars.sh > /dev/null 2>&1
mkdir build
cd build
cmake ..
make
```

3. Save and close the **build.sh** file.

4. Create a **run.sh** script in a text editor.
```
nano run.sh
```

5. Add the following text to the **run.sh** file.
```
source /opt/intel/inteloneapi/setvars.sh > /dev/null 2>&1
cd build
make run
```

6. Save and close the **run.sh** file.

### Build and Run the Sample

Jobs submitted in batch mode are placed in a queue waiting for the necessary resources (compute nodes) to become available. The jobs are executed on a first-come, first-run basis on the first available node(s) having the requested property or label.

1. Build the sample on a GPU node.
```
qsub -l nodes=1:gpu:ppn=2 -d . build.sh
```
- `-l nodes=1:gpu:ppn=2` (lower case L) assigns one full GPU node to the job.
- `-d .` configures the current folder as the working directory for the task.

2. Use the qstat utility to inspect the job progress.
```
watch -n 1 qstat -n -1
```
- The watch `-n 1` command is used to run `qstat -n -1` and display its results every second.

When the build job completes, there will be a **build.sh.oXXXXXX** file in the directory.

> **Note**: Some files are written to the disk when each job terminates.
>- **<script_name>.sh.eXXXX** = the job stderr
> - **<script_name>.sh.oXXXX** = the job stdout
> - where **XXXX** is the job ID printed to the screen after each qsub command.

3. Once the job completes, run the sample on a GPU node.
```
qsub -l nodes=1:gpu:ppn=2 -d . run.sh
```
4. Inspect the output of the sample.
```
cat run.sh.oXXXX
```
### Example Output in Intel&reg; DevCloud

You should see output similar to the following:
```
Platform Name: Intel(R) OpenCL HD Graphics
Platform Version: OpenCL 2.1
Device Name: Intel(R) Gen9 HD Graphics NEO
Max Work Group: 256
Max Compute Units: 24

Parallel Mandelbrot set using buffers.
Rendered image output to file: mandelbrot.png (output too large to display in text)
Serial time: 0.0430331s
Parallel time: 0.00224131s
Successfully computed Mandelbrot set.
```
5. Optionally, remove the stdout and stderr files and clean-up the project files.
```
rm build.sh.*; rm run.sh.*; make clean
```
6. Disconnect from the Intel&reg; DevCloud.
```
exit
```
## License
Code samples are licensed under the MIT license. See
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.

Third party program licenses are at [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).
Third party program licenses are at [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<SYCLWarningLevel>Level3</SYCLWarningLevel>
<AdditionalIncludeDirectories>$(ONEAPI_ROOT)dev-utilities\latest\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ONEAPI_ROOT)\include\;$(ONEAPI_ROOT)\dev-utilities\latest\include\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -88,7 +88,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<SYCLWarningLevel>Level3</SYCLWarningLevel>
<AdditionalIncludeDirectories>$(ONEAPI_ROOT)dev-utilities\latest\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ONEAPI_ROOT)\include\;$(ONEAPI_ROOT)\dev-utilities\latest\include\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
Loading