Commit 29deb329 authored by Mario Bajer's avatar Mario Bajer
Browse files

threaded mult mit c by ref

parent 9f002cd5
......@@ -8,8 +8,8 @@
#include <thread>
#define MAX_THREADS 4
void callMult(Matrix* a, Matrix* b, Matrix c, size_t from, size_t to){ // c auch als ref!
c.threadedmult(a,b,from,to);
void callMult(Matrix* a, Matrix* b, Matrix *c, size_t from, size_t to){ // c auch als ref!
c->threadedmult(a,b,from,to);
}
int main(){
......@@ -55,16 +55,16 @@ int main(){
auto start = std::chrono::high_resolution_clock::now();
if(stoi(matrixA[2]) >= (2 * MAX_THREADS)) {
for (size_t i = 0; i < MAX_THREADS; i++) {
matrixthread[i] = thread(callMult, &a, &b, c, (i * tsize), (i * tsize) + tsize - 1); // c als ref
matrixthread[i] = thread(callMult, &a, &b, &c, (i * tsize), (i * tsize) + tsize - 1); // c als ref
}
for (size_t i = 0; i < MAX_THREADS; i++) {
matrixthread[i].join();
}
if ((tsize % MAX_THREADS) != 0) {
callMult(&a, &b, c, dimyA - (tsize % MAX_THREADS), dimyA);
callMult(&a, &b, &c, dimyA - (tsize % MAX_THREADS), dimyA);
}
}else{
callMult(&a, &b, c, 0, stoi(matrixA[2]));
callMult(&a, &b, &c, 0, stoi(matrixA[2]));
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment