Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Heatmap/Heatmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Heatmap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all: heatmap
heatmap: main.cpp
g++ main.cpp -o heat -fopenmp
clean:
rm -rf heat
24 changes: 24 additions & 0 deletions Heatmap/heatmap_script.py
Original file line number Diff line number Diff line change
@@ -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)
55 changes: 55 additions & 0 deletions Heatmap/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>
#include <iomanip>
#include <fstream>
#include <omp.h>
#include <sys/time.h>
#include <climits>
#include <string>


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;
}

4 changes: 4 additions & 0 deletions OpenMP3/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <omp.h>
#include <cmath>

enum Const
{
NUM_PLACES = 100
};
double func(double x)
{
return sin(x);
Expand Down