# Set up the target environment and compile the application

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/)
- [Set up the target environment and compile the application](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/1-setup/)
- [Identify application bottlenecks with the CPU Microarchitecture recipe](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/2-run-cpu-uarch/)
- [Analyze SIMD utilization with the Instruction Mix recipe](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/3-instruction-mix/)
- [Next Steps](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/_next-steps/)

## About the sample application
To analyze performance bottlenecks, you need an environment and a sample application to profile. In this section, you configure an Arm Performix connection and build a Mandelbrot set generator.

A Mandelbrot set generator is a classic computer science application used to test computational performance. It calculates a famous mathematical fractal by performing intense, repeated mathematical operations (often floating-point) for every pixel in a large image. Because the math for each pixel is independent of the others, it’s a highly parallelizable workload that’s perfect for demonstrating CPU optimizations like vectorization and loop unrolling.

## Before you begin
Make sure Arm Performix is installed on your host machine. The host machine is your local computer where the Arm Performix GUI runs, and it can be a Windows, macOS, or Linux machine. The target machine is the Linux server where your application is compiled and where the application runs.

If you don’t have Arm Performix installed, see the [Arm Performix install guide](https://learn.arm.com/install-guides/performix/).

From the host machine, open the Arm Performix application and navigate to the **Targets** tab. Set up an SSH connection to the target that runs the workload, and test the connection. For the examples in this guide, you connect to an Arm Neoverse-based server.

The Arm Performix collection agent requires Python and `binutils` to run on the target machine.

Connect to your target machine using SSH and install these required OS packages. This includes the GNU C++ compiler.

For Ubuntu and other Debian-based distributions, run the following command:
```bash
sudo apt-get install python3 python3-venv build-essential -y
```

## Build the sample application on the target machine
Download the sample application from GitHub, which is a Mandelbrot set generator provided under the [Arm Education License](https://github.com/ArmDeveloperEcosystem/mandelbrot-example?tab=License-1-ov-file).

```bash
cd $HOME
git clone https://github.com/ArmDeveloperEcosystem/mandelbrot-example.git && cd mandelbrot-example/
```

Run the provided setup script to build the baseline application:
```bash
./build.sh baseline
```
This builds the scalar version of the application, no vectorization is used.

When the build completes, a binary named `mandelbrot-baseline` is created in the `./builds` directory.

The application requires one argument: the number of threads to use. Run this new executable with 4 threads:
```bash
./builds/mandelbrot-baseline 4
```
The application generates a bitmap image file, `Green-Parallel-512.bmp` that looks similar to the following fractal:

![Mandelbrot Set](https://learn.arm.com/learning-paths/servers-and-cloud-computing/performix-microarchitecture/./green-parallel-512.webp)

## What you’ve learned and what’s next
In this section:
- You set up the target machine and established an SSH connection.
- You downloaded, compiled, and ran the baseline Mandelbrot application.

Next, you’ll use the CPU Microarchitecture recipe to identify performance bottlenecks in the application.
