1 Hello world

Aims:

#include <cstdio>
#include "omp.h"

int main()
{

    #pragma omp parallel
    {
        if (omp_get_thread_num()==5)
        {
            printf("Thread #%d reports: This program uses %d threads.\n", omp_get_thread_num(), omp_get_num_threads());
        }

        printf("Hello world from thread #%d\n", omp_get_thread_num());
    }
    return 0;
}

2 Hardware exploration

Aims:

#!/bin/bash             
#SBATCH -t 5            # Request 5 minutes of time
#SBATCH -p test.q       # This selects machines from the queue test.q
#SBATCH -N 1            # We want just one compute node

# This is the command we run
lscpu

Correct answer: 24

Core(s) per socket:    12
Socket(s):             2

3 Message descrambling

Aims:

#include <cstdio>  // Import the printf function
#include "omp.h"   // Import the OpenMP library functions

// Start of program
int main()
{

   // This is a "character array", consisting of 105 letters in byte form.
  char mysecret[] = "Zpv!uijol!zpvs!qbjo!boe!zpvs!ifbsucsfbl!bsf!voqsfdfefoufe!jo!uif!ijtupsz!pg!uif!xpsme-!cvu!uifo!zpv!sfbe/";

   // The original message was encoded by shifting all letters by one, i.e. 
   // A becomes B, c becomes d and so forth. This shift is easy to implement
   // in byte form as all you need to do is to add 1 to a character.
   // To printf a single character, use e.g. 
   //       printf("%c\n", mysecret[0]);
   // To printf the whole array do e.g.   (subtle difference between %c and %s)
   //       printf("%s\n", mysecret);
    
#pragma omp parallel for 
  for (int i=0;i<105;i++) 
  { 
     mysecret[i] -=1;
     printf("Thread [%d] sees %c\n", omp_get_thread_num(), mysecret[i]); 
  }
  printf("%s\n", mysecret);
  return 0;
}

Solution: You think your pain and your heartbreak are unprecedented in the history of the world, but then you read.