c_timers.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "mpi.h"
  17. double start[64], elapsed[64];
  18. /*****************************************************************/
  19. /****** T I M E R _ C L E A R ******/
  20. /*****************************************************************/
  21. void timer_clear( int n )
  22. {
  23. elapsed[n] = 0.0;
  24. }
  25. /*****************************************************************/
  26. /****** T I M E R _ S T A R T ******/
  27. /*****************************************************************/
  28. void timer_start( int n )
  29. {
  30. start[n] = MPI_Wtime();
  31. }
  32. /*****************************************************************/
  33. /****** T I M E R _ S T O P ******/
  34. /*****************************************************************/
  35. void timer_stop( int n )
  36. {
  37. double t, now;
  38. now = MPI_Wtime();
  39. t = now - start[n];
  40. elapsed[n] += t;
  41. }
  42. /*****************************************************************/
  43. /****** T I M E R _ R E A D ******/
  44. /*****************************************************************/
  45. double timer_read( int n )
  46. {
  47. return( elapsed[n] );
  48. }