timers.c 1.2 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 "RCCE.h"
  17. #ifdef _OPENMP
  18. #include "omp.h"
  19. #endif
  20. #include "timers.h"
  21. #define elapsed(n) elapsed[n-1]
  22. #define start(n) start[n-1]
  23. void timer_clear(int *np){
  24. int n = *np;
  25. elapsed(n) = 0.0;
  26. return;
  27. }
  28. void timer_start(int *np) {
  29. int n = *np;
  30. start(n) = RCCE_wtime();
  31. return;
  32. }
  33. void timer_stop(int *np) {
  34. int n = *np;
  35. double t, now;
  36. now = RCCE_wtime();
  37. t = now - start(n);
  38. elapsed(n) = elapsed(n) + t;
  39. return;
  40. }
  41. double timer_read(int *np) {
  42. int n = *np;
  43. return( elapsed(n));
  44. }