Guest User

Untitled

a guest
Jan 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. void initArrays(float* x, float* y,int N){
  2. for(int i=0;i<N;i++){
  3. x[i] = 1;
  4. y[i] = 2;
  5. }
  6. }
  7.  
  8. void addArrays(float*x,float* y,int N){
  9. for(int i=0;i<N;i++)
  10. y[i] = x[i] + y[i];
  11. }
  12.  
  13. int main(void)
  14. {
  15. int N = 1<<20;
  16. float *x, *y;
  17.  
  18. x = (float*)malloc(N*sizeof(float));
  19. y = (float*)malloc(N*sizeof(float));
  20. initArrays(x,y,N);
  21. addArrays(x,y,N);
  22.  
  23. free(x);
  24. free(y);
  25.  
  26. }
Add Comment
Please, Sign In to add comment