Skip to content

Complete tutorial 5#22

Open
AwesomeTornado wants to merge 9 commits into
mainfrom
Complete-Tutorial-5
Open

Complete tutorial 5#22
AwesomeTornado wants to merge 9 commits into
mainfrom
Complete-Tutorial-5

Conversation

@AwesomeTornado
Copy link
Copy Markdown
Collaborator

Closes #14 by adding profiling commands and handling.
Requesting review from @mhmokhtarabadi @elsevers @noguchi-takahiro

Notes

Timing statistics before adding slowdown code.
Image

Timing statistics after adding slowdown code.
Image

The slowdown was done by measuring the time between task start and current time, and not exiting until the difference was larger than 50us.

double time_diff(double initial_time){
	return cpu_timer_ticks_to_usec(cpu_timer_now()) - initial_time;
}

void task_uInverter_callback(void *arg){
    //start stopwatch
    double stopwatch = cpu_timer_ticks_to_usec(cpu_timer_now());
    /*... run task logic ...*/
    while(time_diff(stopwatch) < 50/*us*/){
        //Need to delay for some time.
        for(int i = 0; i < 100; i++){
    	    double a = (double)i / 7; // Floating point division has the potential to be slow.
        }
    }
}

Loop time is the time between task runs. If a task is run every second, the loop time is one second. This is not impacted by task speed, so long as the task finishes before it is run again.
Run time is the actual time it takes a task to run. A slower task will always have a longer time here.

The period of a 10kHz signal is 100us, thus the maximum allowable runtime for a 10kHz task is also 100us.

Self-Review

  1. Are all files under 300 kB (if not, please carefully assess whether it is worth committing them)? Yes
  2. Are all files named according to the appropriate naming convention, i.e., dash-case, camelCase, snake case? Yes
  3. Do all Markdown files follow the CONTRIBUTING article template? N/A
  4. Do all links work in the material that the PR is adding? N/A
  5. Is the PR configured to close the correct issue(s)? Yes
  6. Did the PR fully address the Approach section of the issue(s) it is closing? Yes

Reviewer Instructions

Reviewers, please copy and paste a suitable review checklist into your review and answer all questions.

Appendix

This section should be the same for all PRs. Do not edit this section when creating a PR.

Review Checklists

Checklists maintained by the eLev lab for research repositories include:

Standard checklist

1. Are all files under 300 kB (if not, please carefully assess whether it is worth committing them)? **Yes or No**
2. Are all files named according to the appropriate [naming convention](https://github.com/Severson-Group/research-repo-template?tab=readme-ov-file#file-naming), i.e., dash-case, camelCase, snake case? **Yes or No**
3. Do all Markdown files follow the [CONTRIBUTING article template](https://github.com/Severson-Group/.github/blob/main/CONTRIBUTING.md#markdown-documentation-template)? **Yes or No**
4. Do all links work in the material that the PR is adding? **Yes or No**
5. Is the PR configured to close the correct issue(s)? **Yes or No**
6. Did the PR fully address the `Approach` section of the issue(s) it is closing? **Yes or No**

Please work on addressing any **No** items.

@noguchi-takahiro
Copy link
Copy Markdown
Contributor

@mhmokhtarabadi I think this PR is ready for you. Could you review this PR when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a GitHub PR that implements tutorial 5 (profiling tasks)

2 participants