exchange_6.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_6(double *g, int jbeg, int jfin1) {
  25. int k;
  26. size_t chunk;
  27. double bufin[COMM_SIZE], bufout[COMM_SIZE];
  28. //c---------------------------------------------------------------------
  29. //c communicate in the east and west directions
  30. //c---------------------------------------------------------------------
  31. //c---------------------------------------------------------------------
  32. //c receive from east
  33. //c---------------------------------------------------------------------
  34. if (jfin1 == ny) {
  35. RCCE_recv((char*)bufin, nz*sizeof(double), east);
  36. for (k=1; k<=nz; k++) {
  37. g(ny+1,k) = bufin[k-1];
  38. }
  39. }
  40. //c---------------------------------------------------------------------
  41. //c send west
  42. //c---------------------------------------------------------------------
  43. if (jbeg == 1) {
  44. for (k=1; k<=nz; k++) bufout[k-1] = g(1,k);
  45. RCCE_send((char*)bufout, nz*sizeof(double), west);
  46. }
  47. return;
  48. }