Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdio.h>
  4. #include <windows.h>
  5. #include <chrono>
  6. #include <cstdlib>
  7. using namespace std;
  8. SYSTEMTIME st;
  9.  
  10. #define BILLION 1000000000L;
  11.  
  12. int main() {
  13.  
  14. int n = 32;
  15. float A[1024];
  16. float B[1024];
  17. float C[1024];
  18.  
  19. for (int i = 0; i < 1024; i++) {
  20. A[i] = rand() % 100 + 1;
  21. B[i] = rand() % 100 + 1;
  22. C[i] = rand() % 100 + 1;
  23. }
  24. cout << B[542] << endl << A[754] << endl;
  25. /*int **A = new int*[32];
  26. for(int i = 0; i < 32; ++i) {
  27. A[i] = new int[32];
  28. }
  29. int **B = new int*[32];
  30. for(int i = 0; i < 32; ++i) {
  31. B[i] = new int[32];
  32. }
  33. int **C = new int*[32];
  34. for(int i = 0; i < 32; ++i) {
  35. C[i] = new int[32];
  36. }*/
  37.  
  38. //int C[32][32];
  39. //int A[32][32];
  40. //int B[32][32];
  41. /*
  42. struct timespec start_time;
  43. struct timespec stop_time;
  44.  
  45. SYSTEMTIME st;
  46.  
  47. GetSystemTime(&st);
  48. cout << st.wMilliseconds << endl;
  49. //clock_gettime(CLOCK_REALTIME, &start_time);
  50. */
  51. auto start = std::chrono::high_resolution_clock::now();
  52. for (int k = 0; k < 8; k++) {
  53. for (int i = 0; i < n; i++)
  54. for (int j = 0; j < n; j++) {
  55. C[i + j * n] = 0;
  56. for (int k = 0; k < n; k++)
  57. C[i + j * n] += A[i + k * n] * B[k + n * j];
  58. }
  59. }
  60. //clock_gettime(CLOCK_REALTIME, &stop_time);
  61.  
  62. //double dSeconds = (stop_time.tv_sec - start_time.tv_sec);
  63. //double dNanoSeconds = (double)(stop_time.tv_nsec - start_time.tv_nsec) / BILLION;
  64. auto finish = std::chrono::high_resolution_clock::now();
  65. cout << chrono::duration_cast<chrono::microseconds > (finish - start).count() << "micros\n";
  66. //cout << dNanoSeconds << endl;
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement