exchange_5.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Copyright 2010 Intel Corporation
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include "RCCE.h"
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include "directions.h"
  20. #include "applu_share.h"
  21. #include "applu_macros.h"
  22. #define g(i,j) g[i+(isiz2+2)*(j)]
  23. #define COMM_SIZE 1024
  24. void exchange_5(double *g, int ibeg, int ifin1) {
  25. int k;
  26. size_t chunk;
  27. double bufin[COMM_SIZE], bufout[COMM_SIZE];
  28. //c---------------------------------------------------------------------
  29. //c communicate in the south and north directions
  30. //c---------------------------------------------------------------------
  31. //c---------------------------------------------------------------------
  32. //c receive from south
  33. //c---------------------------------------------------------------------
  34. if (ifin1 == nx) {
  35. RCCE_recv((char*)bufin, nz*sizeof(double), south);
  36. for (k=1; k<=nz; k++) g(nx+1,k) = bufin[k-1];
  37. }
  38. //c---------------------------------------------------------------------
  39. //c send north
  40. //c---------------------------------------------------------------------
  41. if (ibeg == 1) {
  42. for (k=1; k<=nz; k++) bufout[k-1] = g(1,k);
  43. RCCE_send((char*)bufout, nz*sizeof(double), north);
  44. }
  45. return;
  46. }