diff --git a/Heatmap/Heatmap.png b/Heatmap/Heatmap.png new file mode 100644 index 0000000..3fc4b44 Binary files /dev/null and b/Heatmap/Heatmap.png differ diff --git a/Heatmap/Makefile b/Heatmap/Makefile new file mode 100644 index 0000000..65996b3 --- /dev/null +++ b/Heatmap/Makefile @@ -0,0 +1,5 @@ +all: heatmap +heatmap: main.cpp + g++ main.cpp -o heat -fopenmp +clean: + rm -rf heat \ No newline at end of file diff --git a/Heatmap/heatmap_script.py b/Heatmap/heatmap_script.py new file mode 100644 index 0000000..29e7816 --- /dev/null +++ b/Heatmap/heatmap_script.py @@ -0,0 +1,24 @@ +import os +import numpy as np +import matplotlib.pyplot as plt + +def test_heatmap(n_of_external_threads, n_of_internal_threads, heat_matrix): + for external in range(0, n_of_external_threads, 2): + for internal in range(0, n_of_internal_threads, 2): + cmd = './heat ' + str(external) + ' ' + str(internal) + heat_value = os.popen(cmd).read() + print(heat_value) + heat_matrix[external][internal] = heat_value + + +def draw(heat_matrix): + plt.imshow(heat_matrix, cmap='hot', interpolation='nearest') + plt.show() + +if __name__ == "__main__": + n_of_external_threads = 8 + n_of_internal_threads = 32 + heat_matrix = np.zeros((n_of_external_threads, n_of_internal_threads)) + + test_heatmap(n_of_external_threads, n_of_internal_threads, heat_matrix) + draw(heat_matrix) \ No newline at end of file diff --git a/Heatmap/main.cpp b/Heatmap/main.cpp new file mode 100644 index 0000000..8e27d11 --- /dev/null +++ b/Heatmap/main.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include + + +int create_threads(int n_of_threads); +long int ReadArg(char * str); + +int main(int argc, char** argv) +{ + return 0; +} + +int create_threads(int n_of_threads) +{ + int res = 0; + #pragma omp parallel num_threads(n_of_threads) + { + res++; + } + return res; +} + +long int ReadArg(char * str) +{ + char* endptr; + errno = 0; + + long int number = strtol(str, &endptr, 10); + + + if ((errno == ERANGE && (number == LONG_MAX || number == LONG_MIN)) || (errno != 0 && number == 0)) + { + perror("strtol"); + exit(EXIT_FAILURE); + } + + if (endptr == str) + { + fprintf(stderr, "Error!\n"); + exit(EXIT_FAILURE); + } + if (*endptr != '\0') + { + fprintf(stderr, "Error!\n"); + exit(EXIT_FAILURE); + } + + return number; +} + diff --git a/OpenMP3/src/main.cpp b/OpenMP3/src/main.cpp index 416ee06..2ab70c4 100644 --- a/OpenMP3/src/main.cpp +++ b/OpenMP3/src/main.cpp @@ -4,6 +4,10 @@ #include #include +enum Const +{ + NUM_PLACES = 100 +}; double func(double x) { return sin(x);