Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdio.h>
- #include <windows.h>
- #include <chrono>
- #include <cstdlib>
- using namespace std;
- SYSTEMTIME st;
- #define BILLION 1000000000L;
- int main() {
- int n = 32;
- float A[1024];
- float B[1024];
- float C[1024];
- for (int i = 0; i < 1024; i++) {
- A[i] = rand() % 100 + 1;
- B[i] = rand() % 100 + 1;
- C[i] = rand() % 100 + 1;
- }
- cout << B[542] << endl << A[754] << endl;
- /*int **A = new int*[32];
- for(int i = 0; i < 32; ++i) {
- A[i] = new int[32];
- }
- int **B = new int*[32];
- for(int i = 0; i < 32; ++i) {
- B[i] = new int[32];
- }
- int **C = new int*[32];
- for(int i = 0; i < 32; ++i) {
- C[i] = new int[32];
- }*/
- //int C[32][32];
- //int A[32][32];
- //int B[32][32];
- /*
- struct timespec start_time;
- struct timespec stop_time;
- SYSTEMTIME st;
- GetSystemTime(&st);
- cout << st.wMilliseconds << endl;
- //clock_gettime(CLOCK_REALTIME, &start_time);
- */
- auto start = std::chrono::high_resolution_clock::now();
- for (int k = 0; k < 8; k++) {
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++) {
- C[i + j * n] = 0;
- for (int k = 0; k < n; k++)
- C[i + j * n] += A[i + k * n] * B[k + n * j];
- }
- }
- //clock_gettime(CLOCK_REALTIME, &stop_time);
- //double dSeconds = (stop_time.tv_sec - start_time.tv_sec);
- //double dNanoSeconds = (double)(stop_time.tv_nsec - start_time.tv_nsec) / BILLION;
- auto finish = std::chrono::high_resolution_clock::now();
- cout << chrono::duration_cast<chrono::microseconds > (finish - start).count() << "micros\n";
- //cout << dNanoSeconds << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement