From 9fd75406f3f9643d69f8785063283d85a286b44a Mon Sep 17 00:00:00 2001 From: Kent Milfeld Date: Sat, 21 Oct 2023 15:10:55 -0500 Subject: [PATCH] Updated timer.hpp and timer.f90 to be consistent. Fleshed out time_add gpu exercise. --- OpenMP_cpu/adv_intro/2_timers/README_timer.md | 35 +++++---- .../adv_intro/2_timers/solutions/ans_output | 14 +++- .../2_timers/solutions/ans_time_print.cpp | 4 +- .../2_timers/solutions/ans_time_print.f90 | 6 +- OpenMP_cpu/adv_intro/2_timers/time_print.cpp | 2 +- OpenMP_cpu/adv_intro/2_timers/time_print.f90 | 2 +- OpenMP_cpu/adv_intro/2_timers/timer.f90 | 18 ++--- OpenMP_cpu/adv_intro/2_timers/timer.hpp | 29 +++---- OpenMP_gpu/adv/time_add/README_time_add.md | 47 +++++++++-- OpenMP_gpu/adv/time_add/add.F90 | 66 ++++++++++++++++ OpenMP_gpu/adv/time_add/add.cpp | 72 ++++++++--------- OpenMP_gpu/adv/time_add/timer.f90 | 78 +++++++++++++++++++ OpenMP_gpu/adv/time_add/timer.hpp | 29 +++---- OpenMP_gpu/basic/worksharing/README.md | 58 +++++++++----- .../solutions/Intel_needs_mcmodel_error | 16 ++++ .../solutions/ans_opt_worksharing.cpp | 36 +++++++++ .../solutions/ans_opt_worksharing.f90 | 40 ++++++++++ .../worksharing/solutions/ans_worksharing.cpp | 8 +- .../worksharing/solutions/ans_worksharing.f90 | 34 ++++++++ OpenMP_gpu/basic/worksharing/timer.f90 | 78 +++++++++++++++++++ OpenMP_gpu/basic/worksharing/timer.hpp | 30 +++---- OpenMP_gpu/basic/worksharing/worksharing.f90 | 33 ++++++++ 22 files changed, 598 insertions(+), 137 deletions(-) create mode 100644 OpenMP_gpu/adv/time_add/add.F90 create mode 100644 OpenMP_gpu/adv/time_add/timer.f90 create mode 100644 OpenMP_gpu/basic/worksharing/solutions/Intel_needs_mcmodel_error create mode 100644 OpenMP_gpu/basic/worksharing/solutions/ans_opt_worksharing.cpp create mode 100644 OpenMP_gpu/basic/worksharing/solutions/ans_opt_worksharing.f90 create mode 100644 OpenMP_gpu/basic/worksharing/solutions/ans_worksharing.f90 create mode 100644 OpenMP_gpu/basic/worksharing/timer.f90 create mode 100644 OpenMP_gpu/basic/worksharing/worksharing.f90 diff --git a/OpenMP_cpu/adv_intro/2_timers/README_timer.md b/OpenMP_cpu/adv_intro/2_timers/README_timer.md index ecc5c05..60c4a52 100644 --- a/OpenMP_cpu/adv_intro/2_timers/README_timer.md +++ b/OpenMP_cpu/adv_intro/2_timers/README_timer.md @@ -1,47 +1,56 @@ -# Class Timer -- collects time measurements and reports them later. +# Class Timer_Collector -- collects time measurements and reports them later. ## BACKGROUND Fortran and CPP Timer classes have been created for measuring performance of code blocks demarked by start() and stop() class member functions. For each block a literal character string argument for start("my label") is used as a label when the times are reported with print(). - -See timer.hpp (CPP) and timer.f90 (F90) - +``` + Declare Timer_collector as timer + CPP F90 + timer.start("my label") call timer%start("my label") + + timer.stop() call timer%stop() + ... ... + timer.print() call timer%print() + + See timer.hpp (CPP) and timer.f90 (F90) + +``` ## Exercises 1.) - Look over time_print(.cpp|.f90). The todo's guide you + Look over time_print(.cpp|.f90). The TODOs guide you through instrumenting the code for timing a sleep routine, and - -- That's just to make sure the timer is working.--- + -- That is just to make sure the timer is working.--- a write to stdout (CPP: printf, F90: print*,) TODO 1: - Include the Timer class file (CPP: timer.hpp, F90: timer.f90) + Include the Timer_collector class file (CPP: timer.hpp, F90: timer.f90) at the beginning of the code. TODO 2: Instantiate the class in main as timer: - CPP: Just use "Timer time;" + CPP: Just use "Timer_Collector timer;" F90: Use the module defined in timer.f90 (mod_timer) - and define timer as type(cls_timer). + and define "timer" as type(Timer_Collector). TODO 3: Time the sleep and print statements: - Put time.start("