Building the Source Code

In this step, you will compile the source code into an application that runs on both the CPU and the coprocessor and then run the application. To compile the source code, run the specified command in the same terminal session from the previous step. If you open a new terminal session, you will have to set the environment variables in the new terminal session.

  1. In the sample code directory, compile the source code into the application with the following command:

    ifort -openmp tbo_sort.F90 -o tbo_exe_MIC

    By default, the compiler compiles the source code into an application that can run on both the CPU and the coprocessor. The -openmp option sets the compiler to use the parallelizer to generate multi-threaded code based on OpenMP* directives.

  2. Run the application with the following command.

    ./tbo_exe_MIC

The application displays the number of coprocessors or target devices in the system. The application then displays the first 20 values in ascending order. Finally, the application displays the first ten even, odd, and prime numbers.

While most of the code runs on the CPU, the code to find the first ten even, odd, and prime numbers runs on the coprocessor. Later in this tutorial, you will see the how these code sections are defined.

After running the application, you can look at the source code to learn how the application determines if the system has a running coprocessor and count the number of running coprocessors. In the next step, you will look at the source code in your favorite editor to find the section that gives more information about the coprocessors in the system.

Open the Preparing the Sample Application topic Open the Building the OpenMP Version topic


Submit feedback on this help topic
Click here for more Getting Started Tutorials