Skip to content

Instantly share code, notes, and snippets.

@NielsMinssen
Created June 2, 2023 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NielsMinssen/090cddc8f666528658fd136c28bb908e to your computer and use it in GitHub Desktop.
Save NielsMinssen/090cddc8f666528658fd136c28bb908e to your computer and use it in GitHub Desktop.
#include <omp.h>
#define SIZE 1000
double A[SIZE][SIZE];
double B[SIZE][SIZE];
double C[SIZE][SIZE];
int main() {
// Initialize A and B
omp_set_num_threads(4);
// Parallélisation
#pragma omp parallel for
for(int i = 0; i < SIZE; i++) {
for(int j = 0; j < SIZE; j++) {
C[i][j] = 0.0;
for(int k = 0; k < SIZE; k++) {
C[i][j] += A[i][k] * B[k][j];
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment