From 781b96215a2e9a3f24319bdb8bfc545a0c36ee31 Mon Sep 17 00:00:00 2001 From: esther Date: Tue, 23 Apr 2024 20:37:53 +0200 Subject: [PATCH] Wrote on lab 5 about parallelization and definitions. --- documentation/lab5.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/documentation/lab5.md b/documentation/lab5.md index 0083432..5ad9b31 100644 --- a/documentation/lab5.md +++ b/documentation/lab5.md @@ -2,6 +2,10 @@ ## dynamic library Dynamic libraries are libraries are pre compiled and often provided by the operating system, as opposed to compiling it as part of your project. This saves space as each program dont need its own "copy". +## command-line arguments +Command-line arguments are extra commands that we enter after the program's executable name so that the functionality of the program changes. + + # 30. Draft slides: See slides.pdf @@ -11,8 +15,24 @@ See slides.pdf # 32 Special interest functionality and responsibilities Per now we dont have time to add any extra functionality. -33. Programming project: Progress on data structure implementation +# 33. Programming project: Progress on data structure implementation ... -34. Parallelization \ No newline at end of file +# 34. Parallelization +The following code was used for parallelization using openMP. We haven't had time to test and we have only parallelized half of what is possible. But we can see that it is using all the cores. + +```` +#pragma omp parallel + { + std::vector vec_private; + #pragma omp for + for (int i = 1; i <= num_contours; i++) + { + vec_private.push_back(produce_cellmap(heightmap, heightmap->min + interval*i)); + std::cout << "Execute thread " << omp_get_num_threads() << " "; + } + #pragma omp critical + vector_contours.insert(vector_contours.end(), vec_private.begin(), vec_private.end()); + } +````