This tutorial describes how to run OpenMP programs in a virtual machine (VM) on Google Cloud Platform (GCP).
Initial steps
As a very first step, we strongly suggest you to go through the FAQ.
Before running your first OpenMP application on GCP, you must go through the following steps:
- Create an account on GCP and activate your Education credits:
- For this step, follow the dedicated tutorial
- Learn how to create (and destroy) a VM with the configuration of your choice using one of the two following options:
- Creating a VM using the gcloud command line tool (recommended solution)
- Creating a VM using the web interface
- Learn how to connect to your VM using SSH:
Reminder: As explained in the tutorials above, don’t forget to delete the resources you created before disconnecting from GCP.
Running OpenMP programs in a VM
Installing OpenMP
The OS that is run inside your VM in the cloud, comes with only a few packages installed by default. Hence, to be able to compile and run OpenMP programs, you first need to install gcc
.
To this end, run the following commands once connected through SSH to your VM:
sudo apt update
sudo apt install gcc
Note that the commands above assume that the OS you selected for your
VM uses apt
as package manager.
Copying files from your workstation to the VM
To copy a file from your workstation to your VM in the cloud, you should use the command line tool scp
. Here is the command to execute on your workstation, to copy file prog.c
into your home
directory in the VM:
scp -i [PATH_TO_PRIVATE_KEY] prog.c [USERNAME]@[EXTERNAL_IP_ADDRESS]:./
Running OpenMP programs
Once you have installed gcc
in your VM and copied there the file with the source code of your program, you can compile and execute your OpenMP program in the same way as on your workstation.