RCCE_pingpong-xt.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <string.h>
  17. #include <stdio.h>
  18. #include "RCCE.h"
  19. #define max(x,y) ((x)>(y)?(x):(y))
  20. int RCCE_APP(int argc, char **argv){
  21. int YOU, ME, nrounds = 1024*1024, actualrounds, size, N=32, round, pair, index;
  22. int bigsize, subindex, roundsize;
  23. double timer;
  24. char buffer[1024*1024*4];
  25. RCCE_init(&argc, &argv);
  26. // RCCE_debug_set(RCCE_DEBUG_ALL);
  27. ME = RCCE_ue();
  28. YOU = !ME;
  29. if (argc>1) nrounds = atoi(*++argv);
  30. if (nrounds<1) {
  31. if (!ME) printf("Pingpong needs at least 1 round; try again\n");
  32. return(1);
  33. }
  34. if (RCCE_num_ues() != 2) {
  35. if (!ME) printf("Pingpong needs at two UEs; try again\n");
  36. return(1);
  37. }
  38. bigsize = 32;
  39. for (index=0; index<17; index++) {
  40. size = bigsize;
  41. for (subindex=0; subindex<4; subindex++) {
  42. roundsize = max(32,size - size%32);
  43. // synchronize before starting the timer
  44. RCCE_barrier(&RCCE_COMM_WORLD);
  45. timer = RCCE_wtime();
  46. actualrounds = max(10,(nrounds*32)/roundsize);
  47. for (round=0; round <actualrounds; round++) {
  48. if (ME) {
  49. RCCE_send(buffer, roundsize, YOU);
  50. RCCE_recv(buffer, roundsize, YOU);
  51. }
  52. else {
  53. RCCE_recv(buffer, roundsize, YOU);
  54. RCCE_send(buffer, roundsize, YOU);
  55. }
  56. }
  57. timer = RCCE_wtime()-timer;
  58. if (ME) printf("%d %1.9lf\n", roundsize, timer/actualrounds);
  59. size *= 1.18920712;
  60. }
  61. bigsize *= 2;
  62. }
  63. RCCE_finalize();
  64. return(0);
  65. }