bt.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. //-------------------------------------------------------------------------!
  2. // !
  3. // N A S P A R A L L E L B E N C H M A R K S 3.3 !
  4. // !
  5. // B T !
  6. // !
  7. //-------------------------------------------------------------------------!
  8. // !
  9. // This benchmark is part of the NAS Parallel Benchmark 3.3 suite. !
  10. // It is described in NAS Technical Reports 95-020 and 02-007. !
  11. // !
  12. // Permission to use, copy, distribute and modify this software !
  13. // for any purpose with or without fee is hereby granted. We !
  14. // request, however, that all derived work reference the NAS !
  15. // Parallel Benchmarks 3.3. This software is provided "as is" !
  16. // without express or implied warranty. !
  17. // !
  18. // Information on NPB 3.3, including the technical report, the !
  19. // original specifications, source code, results and information !
  20. // on how to submit new results, is available at: !
  21. // !
  22. // http://www.nas.nasa.gov/Software/NPB/ !
  23. // !
  24. // Send comments or suggestions to npb@nas.nasa.gov !
  25. // !
  26. // NAS Parallel Benchmarks Group !
  27. // NASA Ames Research Center !
  28. // Mail Stop: T27A-1 !
  29. // Moffett Field, CA 94035-1000 !
  30. // !
  31. // E-mail: npb@nas.nasa.gov !
  32. // Fax: (650) 604-3957 !
  33. // !
  34. //-------------------------------------------------------------------------!
  35. //
  36. // Copyright 2010 Intel Corporation
  37. //
  38. // Licensed under the Apache License, Version 2.0 (the "License");
  39. // you may not use this file except in compliance with the License.
  40. // You may obtain a copy of the License at
  41. //
  42. // http://www.apache.org/licenses/LICENSE-2.0
  43. //
  44. // Unless required by applicable law or agreed to in writing, software
  45. // distributed under the License is distributed on an "AS IS" BASIS,
  46. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  47. // See the License for the specific language governing permissions and
  48. // limitations under the License.
  49. //
  50. //---------------------------------------------------------------------
  51. //
  52. // Authors: R. F. Van der Wijngaart
  53. // T. Harris
  54. // M. Yarrow
  55. //
  56. //---------------------------------------------------------------------
  57. #include <stdio.h>
  58. #include <string.h>
  59. #include "RCCE.h"
  60. #include "applu_macros.h"
  61. #define G_MAIN
  62. #include "header.h"
  63. #include "mpinpb.h"
  64. #define BSIZE 132
  65. void make_color(void);
  66. void print_results(char*, char, int, int, int, int, int, int, double,
  67. double, char*, int, char*, char*, char*, char*,
  68. char*, char*, char*, char*);
  69. //---------------------------------------------------------------------
  70. // program MPBT;
  71. //---------------------------------------------------------------------
  72. int RCCE_APP(int argc, char **argv) {
  73. int N = 1000, nothing;
  74. int i, niter, step, c, error, fstatus;
  75. double navg, mflops, mbytes, n3;
  76. RCCE_COMM aux[N];
  77. double t, tmax, tiominv, tpc;
  78. int verified;
  79. char class;
  80. size_t chunk;
  81. char cbuf[BSIZE];
  82. if (setup_mpi(&argc, &argv)) {
  83. RCCE_finalize();
  84. return 0;
  85. }
  86. // RCCE_debug_set(RCCE_DEBUG_ALL);
  87. //---------------------------------------------------------------------
  88. // Root node reads input file (if it exists) else takes
  89. // defaults from parameters
  90. //---------------------------------------------------------------------
  91. if (node == root) {
  92. printf("\n\n NAS Parallel Benchmarks 3.3 -- BT Benchmark\n");
  93. }
  94. niter = NITER_DEFAULT;
  95. dt = dt_default;
  96. grid_points(1) = PROBLEM_SIZE;
  97. grid_points(2) = PROBLEM_SIZE;
  98. grid_points(3) = PROBLEM_SIZE;
  99. if (node == root) {
  100. printf(" Size: %4dx%4dx%4d\n",
  101. grid_points(1), grid_points(2), grid_points(3));
  102. printf(" Iterations: %4d dt: %11.7f\n", niter, dt);
  103. if (no_nodes != total_nodes)
  104. printf(" Total number of processes: %5d\n", total_nodes);
  105. if (no_nodes != MAXCELLS*MAXCELLS)
  106. printf(" WARNING: compiled for %5d processes\n",
  107. MAXCELLS*MAXCELLS);
  108. printf(" Number of active processes: %5d\n\n", no_nodes);
  109. }
  110. make_set();
  111. make_color();
  112. for (c = 1; c <= MAXCELLS; c++) {
  113. if ( (cell_size(1,c) > IMAX) ||
  114. (cell_size(2,c) > JMAX) ||
  115. (cell_size(3,c) > KMAX) ) {
  116. printf(" %d %d %d %d %d\n", node, c, cell_size(1,c),
  117. cell_size(2,c), cell_size(3,c));
  118. printf(" Problem size too big for compiled array sizes\n");
  119. }
  120. }
  121. set_constants();
  122. initialize();
  123. lhsinit();
  124. exact_rhs();
  125. compute_buffer_size(5);
  126. //---------------------------------------------------------------------
  127. // do one time step to touch all code, and reinitialize
  128. //---------------------------------------------------------------------
  129. adi();
  130. initialize();
  131. timer_clear(2);
  132. //---------------------------------------------------------------------
  133. // Synchronize before placing time stamp
  134. //---------------------------------------------------------------------
  135. RCCE_barrier(&RCCE_COMM_WORLD);
  136. timer_clear(1);
  137. timer_start(1);
  138. for (step = 1; step <= niter; step++) {
  139. if (node == root) {
  140. if ((step%20) == 0 || step == niter ||
  141. step == 1) {
  142. printf(" Time step %4d\n", step); fflush(stdout);
  143. }
  144. }
  145. adi();
  146. }
  147. timer_stop(1);
  148. t = timer_read(1);
  149. verify(niter, &class, &verified);
  150. RCCE_reduce((char*)(&t), (char*)(&tmax), 1, RCCE_DOUBLE, RCCE_MAX, root, RCCE_COMM_WORLD);
  151. if( node == root ) {
  152. n3 = 1.0e0*grid_points(1)*grid_points(2)*grid_points(3);
  153. navg = (grid_points(1)+grid_points(2)+grid_points(3))/3.0;
  154. if( tmax != 0. ) {
  155. mflops = 1.0e-6*(double)(niter)*
  156. (3478.8*(double)n3-17655.7*navg*navg+28023.7*navg)
  157. / tmax;
  158. } else {
  159. mflops = 0.0;
  160. }
  161. print_results("BT", class, grid_points[0],
  162. grid_points[1], grid_points[2], niter, MAXCELLS*MAXCELLS,
  163. total_nodes, tmax, mflops, " floating point",
  164. verified, NPBVERSION,COMPILETIME, CS1, CS2, CS3, CS4, CS5,
  165. CS6);
  166. // FILE *perf_file;
  167. // char name[50] = "/shared/DEMOS/RCCE/NPB_BT/perf.";
  168. // char postfix[50];
  169. // sprintf(postfix, "%d", total_nodes);
  170. // strcat(name, postfix);
  171. // perf_file = fopen(name,"w");
  172. // fprintf(perf_file, "%d", (int)mflops);
  173. // fclose(perf_file);
  174. }
  175. RCCE_finalize();
  176. return 0;
  177. }