define.c.svn-base 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //---------------------------------------------------------------------
  2. //
  3. // Copyright 2010 Intel Corporation
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. //---------------------------------------------------------------------
  18. #include "header.h"
  19. void compute_buffer_size(int dim) {
  20. //---------------------------------------------------------------------
  21. //---------------------------------------------------------------------
  22. int c, face_size;
  23. if (ncells == 1) return;
  24. //---------------------------------------------------------------------
  25. // compute the actual sizes of the buffers; note that there is
  26. // always one cell face that doesn't need buffer space, because it
  27. // is at the boundary of the grid
  28. //---------------------------------------------------------------------
  29. west_size = 0;
  30. east_size = 0;
  31. for (c = 1; c <= ncells; c++) {
  32. face_size = cell_size(2,c) * cell_size(3,c) * dim * 2;
  33. if (cell_coord(1,c)!=1) west_size = west_size + face_size;
  34. if (cell_coord(1,c)!=ncells) east_size = east_size +
  35. face_size ;
  36. }
  37. north_size = 0;
  38. south_size = 0;
  39. for (c = 1; c <= ncells; c++) {
  40. face_size = cell_size(1,c)*cell_size(3,c) * dim * 2;
  41. if (cell_coord(2,c)!=1) south_size = south_size + face_size;
  42. if (cell_coord(2,c)!=ncells) north_size = north_size +
  43. face_size ;
  44. }
  45. top_size = 0;
  46. bottom_size = 0;
  47. for (c = 1; c <= ncells; c++) {
  48. face_size = cell_size(1,c) * cell_size(2,c) * dim * 2;
  49. if (cell_coord(3,c)!=1) bottom_size = bottom_size +
  50. face_size;
  51. if (cell_coord(3,c)!=ncells) top_size = top_size +
  52. face_size ;
  53. }
  54. start_send_west = 1;
  55. start_send_east = start_send_west + west_size;
  56. start_send_south = start_send_east + east_size;
  57. start_send_north = start_send_south + south_size;
  58. start_send_bottom = start_send_north + north_size;
  59. start_send_top = start_send_bottom + bottom_size;
  60. start_recv_west = 1;
  61. start_recv_east = start_recv_west + west_size;
  62. start_recv_south = start_recv_east + east_size;
  63. start_recv_north = start_recv_south + south_size;
  64. start_recv_bottom = start_recv_north + north_size;
  65. start_recv_top = start_recv_bottom + bottom_size;
  66. return;
  67. }