Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a thread name to all DALI threads #3912

Merged
merged 9 commits into from
May 24, 2022
Merged

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented May 17, 2022

  • adds an ability to name thread poll and the worker thread
    threads so they are easier to identified on the nsight traces

Signed-off-by: Janusz Lisiecki jlisiecki@nvidia.com

Category:

Other (e.g. Documentation, Tests, Configuration)

Description:

  • adds an ability to name thread poll and the worker thread
    threads so they are easier to identified on the nsight traces

Additional information:

Affected modules and functionalities:

  • worker thread
  • thread pool
  • all places (besides tests) that uses them

Key points relevant for the review:

  • If all places using threads are covered

Checklist

Tests

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

@JanuszL JanuszL marked this pull request as draft May 17, 2022 23:56
@JanuszL JanuszL force-pushed the name_threads branch 10 times, most recently from 77ce73c to ef02b63 Compare May 18, 2022 22:34
@JanuszL JanuszL marked this pull request as ready for review May 18, 2022 22:36
@JanuszL
Copy link
Contributor Author

JanuszL commented May 18, 2022

!build

@JanuszL
Copy link
Contributor Author

JanuszL commented May 18, 2022

image

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4876435]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4876435]: BUILD PASSED

@JanuszL
Copy link
Contributor Author

JanuszL commented May 19, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4879091]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4879091]: BUILD PASSED

@awolant awolant self-assigned this May 19, 2022
Copy link
Contributor

@awolant awolant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to add pthread_getname_np to tests to make sure that it works and keeps working in the future?
Regardless, cool feature.

@JanuszL
Copy link
Contributor Author

JanuszL commented May 20, 2022

Maybe it would be good to add pthread_getname_np to tests to make sure that it works and keeps working in the future? Regardless, cool feature.

@awolant - done

@JanuszL
Copy link
Contributor Author

JanuszL commented May 20, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4893041]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4893041]: BUILD PASSED

@@ -100,6 +100,8 @@ struct DomainTimeRange : RangeBase {
#endif
};

void SetThreadName(const char *name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some docs comment that only first 15 characters of the name will be used?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see it's only for the pthread name. So maybe it's not that important to note

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#else

void SetThreadName(const char *name) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The impl without NVTX enabled still could set the pthread name, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@JanuszL
Copy link
Contributor Author

JanuszL commented May 23, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910165]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910165]: BUILD FAILED

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910272]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910272]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910311]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910314]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910311]: BUILD FAILED

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@@ -66,15 +67,15 @@ class WorkerThread {
public:
typedef std::function<void(void)> Work;

inline WorkerThread(int device_id, bool set_affinity) :
inline WorkerThread(int device_id, bool set_affinity, const std::string name) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline WorkerThread(int device_id, bool set_affinity, const std::string name) :
inline WorkerThread(int device_id, bool set_affinity, const std::string &name) :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


namespace dali {

ThreadPool::ThreadPool(int num_thread, int device_id, bool set_affinity)
ThreadPool::ThreadPool(int num_thread, int device_id, bool set_affinity, const std::string name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ThreadPool::ThreadPool(int num_thread, int device_id, bool set_affinity, const std::string name)
ThreadPool::ThreadPool(int num_thread, int device_id, bool set_affinity, const std::string &name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 37 to 38
DLL_PUBLIC ThreadPool(int num_thread, int device_id, bool set_affinity,
const std::string name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DLL_PUBLIC ThreadPool(int num_thread, int device_id, bool set_affinity,
const std::string name);
DLL_PUBLIC ThreadPool(int num_thread, int device_id, bool set_affinity,
const std::string &name);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@mzient mzient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a few missing &, OK.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4910314]: BUILD FAILED

@JanuszL JanuszL force-pushed the name_threads branch 2 times, most recently from e4b6c19 to eecd062 Compare May 23, 2022 18:00
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4912612]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4912612]: BUILD FAILED

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4912820]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4912820]: BUILD FAILED

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4913316]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4913316]: BUILD PASSED

@JanuszL JanuszL merged commit cad8540 into NVIDIA:main May 24, 2022
@JanuszL JanuszL deleted the name_threads branch May 24, 2022 07:24
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
- adds an ability to name thread poll and the worker thread
  threads so they are easier to identify on the nsight traces
- use NVTX API to set full names visible in nsight traces
  and pthread_setname_np to set truncated names visible in the GDB debugger

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
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.

None yet

5 participants