setup_mpi.c.svn-base 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <math.h>
  19. #include "mpinpb.h"
  20. #include "npbparams.h"
  21. #include "RCCE.h"
  22. int setup_mpi(int *argc, char **argv[]) {
  23. //---------------------------------------------------------------------
  24. //---------------------------------------------------------------------
  25. //---------------------------------------------------------------------
  26. // set up MPI stuff
  27. //---------------------------------------------------------------------
  28. int error, color, nc;
  29. if (error = RCCE_init(argc, argv)) return(error);
  30. total_nodes = RCCE_num_ues();
  31. node = RCCE_ue();
  32. //---------------------------------------------------------------------
  33. // compute square root; add small number to allow for roundoff
  34. //---------------------------------------------------------------------
  35. nc = (int)(sqrt((double)(total_nodes) + 0.00001e0));
  36. //---------------------------------------------------------------------
  37. // We handle a non-square number of nodes by making the excess nodes
  38. // inactive. However, we can never handle more cells than were compiled
  39. // in.
  40. //---------------------------------------------------------------------
  41. if (nc > MAXCELLS) nc = MAXCELLS;
  42. no_nodes = nc*nc;
  43. //---------------------------------------------------------------------
  44. // let node 0 be the root for the group (there is only one)
  45. //---------------------------------------------------------------------
  46. root = 0;
  47. return(0);
  48. }