#include #include #include #include #include "Ttiming.h" using namespace std; void array_alloc(long **&arr, long arrsize) { try { arr = new long* [arrsize]; arr[0] = new long [arrsize*arrsize]; for(long i = 1; i < arrsize; ++i) arr[i] = arr[i-1] + arrsize; } catch (bad_alloc& ex) { cerr << "Could not allocate memory for array" << endl; exit(1); } } void array_destroy(long **arr) { delete [] arr[0]; delete [] arr; } int main(int argc, char *argv[]) { long **A=NULL, **B=NULL, **C=NULL; long rozmiar=0; char *endptr; int threads_num=0; TTiming tt; long i, j;//,k; if (argc < 3) { cerr << "Usage: " << argv[0] << " " << endl; exit(1); } rozmiar = strtol(argv[2], &endptr, 10); if (*endptr) { cerr << "Invalid array size format" << endl; exit(1); } if (rozmiar <= 0) { cerr << "The number of matrix dimension must be positive" << endl; exit(1); } threads_num = strtol(argv[1], &endptr, 10); if (*endptr) { cerr << "Invalid number of threads format" << endl; exit(1); } if (threads_num <= 0) { cerr << "The number of threads must be positive" << endl; exit(1); } //ustawienie odpowiedniej ilosci watkow omp_set_num_threads(threads_num); //alokacja macierzy array_alloc(A, rozmiar); array_alloc(B, rozmiar); array_alloc(C, rozmiar); //wypelnienie macierzy A liczbami "losowymi" for (long i=0; i