Intel® oneAPI HPC Toolkit
An internet connection is required to download the samples for oneAPI toolkits. If you are using an offline system, download the samples from a system that is internet connected and transfer the sample files to your offline system. The samples can be downloaded from here:Intel® oneAPI HPC Toolkit Code Samples
NoteIf you have not already configured your development environment, go to Configure Your System then return to this page. If you have already completed the steps to configure your system, continue with the steps below.
Command line development can be done with a terminal window or done through Visual Studio Code*. For details on how to use VS Code locally, see Basic Usage of Visual Studio Code with oneAPI on Linux*. To use VS Code remotely, see Remote Visual Studio Code Development with oneAPI on Linux*.
To compile and run a sample:
Download Samples using the oneAPI CLI Samples Browser
Use the oneAPI CLI Samples Browser to browse the collection of online oneAPI samples. As you browse the oneAPI samples, you can copy them to your local disk as buildable sample projects. Most oneAPI sample projects are built using Make or CMake, so the build instructions are included as part of the sample in a README file. The oneAPI CLI utility is a single-file, stand-alone executable that has no dependencies on dynamic runtime libraries. You can find the samples browser in the <install-dir>/dev-utilities/latest/bin folder on your development host system.
- Open a terminal window.
- If you did not complete the steps in Option 2: One time set up for setvars.sh, navigate to the install directory, which is typically /opt/intel/inteloneapi/ when installed as root or sudo, and ~/intel/inteloneapi/ when not installed as a super user. If you customized the installation folder, the setvars.sh is in your custom folder.
- Set system variables by running setvars:
The setvars.sh script can also be managed using a configuration file. For more details, see Using a Configuration File to Manage Setvars.sh
- In the same terminal window, run the application (it should be in your PATH):
oneapi-cliThe oneAPI CLI menu appears:
- Move the arrow key down to select Create a project , then press Enter
- Select the language for your sample. For your first project, select cpp, then press Enter. The toolkit samples list appears.
7. Select the Matrix Multiplication sample.
8. After you select a sample, press Enter.
9. Enter an absolute or a relative directory path to create your project. Provide a directory and project name. The Project Name is the name of the sample you chose in the previous step.
10. Press Tab to select Create, then press Enter:
The directory path is printed to the command line.
Now that you have the samples downloaded, compile and run the sample with CMake*
Compile and Run a Sample Using Make*
NoteThe Matrix Multiplier sample does not require CMake*, but manny of the other samples do require CMake. If you have not installed CMake, follow the directions Configure Your System.
Build the matrix_mul Program using Make:
cd matrix_mul && make allRun the Program
make runClean the Program
Create a Project Based on a oneAPI Sample using CMake
To run a different sample using CMake, where <sample_name> is the name of the sample you want to run:
- If necessary, re-run the command-line utility and select a CMake project that contains a CMakeLists.txt file.
cd <sample_name> &&
- Navigate to the build directory.
mkdir build && cd build &&
- Build the program. Run CMake in the build directory to create the makefile. Use the newly created makefile to build the executable.
cmake ../. && make VERBOSE=1
- Run the program.
- Clean the program.