Guest User

Untitled

a guest
Mar 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. //main.cpp
  2. #include "ex_function.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8. float* rand_arr = vec_random(4,false);
  9.  
  10. for (int i = 0; i < 4; i++)
  11. cout << " " << rand_arr[i];
  12. cout << endl;
  13.  
  14. delete[] rand_arr;
  15. return 0;
  16. }
  17.  
  18.  
  19.  
  20. //vec_random.cpp
  21. #include "omp.h"
  22. #include "stdlib.h"
  23. #include "time.h"
  24. #include "ex_function.h"
  25.  
  26. float* vec_random(int n, bool normal)
  27. {
  28. float* rand_arr = new float[n];
  29.  
  30. // ----------------------------------------------------------
  31. //
  32. // ----------------------------------------------------------
  33.  
  34.  
  35. if (normal)
  36. {
  37. #pragma omp barrier
  38. vec_random_norm(rand_arr, n);
  39. }
  40. // ----------------------------------------------------------------------------------------
  41. // -- весь код между этим комментарием и комментарий 1 должен быть в параллельной области--
  42. // ----------------------------------------------------------------------------------------
  43. return rand_arr;
  44. }
  45.  
  46.  
  47. //vec_random_norm.cpp
  48. #include "omp.h"
  49. #include <iostream>
  50. using namespace std;
  51.  
  52. void vec_random_norm(float* rand_arr, int n)
  53. {
  54. }
  55.  
  56.  
  57. //ex_function.h
  58. #pragma once
  59.  
  60. float* vec_random(int n,bool normal);
  61. void vec_random_norm(float* rand_arr, int n);
Add Comment
Please, Sign In to add comment