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

Move all NVTX infrastructure into core and create DALI domain #2472

Merged
merged 5 commits into from
Nov 18, 2020

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented Nov 16, 2020

  • libdali_core now provides NVTX ranges functionality
  • core is responsible for creating one DALI domain
  • regular DALI code should use DomainTimeRange from core lib
  • plain TimeRange is still header-only and should be used only for the development

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

Why we need this PR?

Pick one, remove the rest

  • It moves all NVTX infrastructure into core and create DALI domain

What happened in this PR?

Fill relevant points, put NA otherwise. Replace anything inside []

  • What solution was applied:
    libdali_core now provides NVTX ranges functionality
  • Affected modules and functionalities:
    core
    all modules using NVTX ranges
  • Key points relevant for the review:
    NA
  • Validation and testing:
    CI
  • Documentation (including examples):
    NA

JIRA TASK: [DALI-1728]

@JanuszL
Copy link
Contributor Author

JanuszL commented Nov 16, 2020

!build

@JanuszL
Copy link
Contributor Author

JanuszL commented Nov 16, 2020

image

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1803789]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1803789]: BUILD FAILED

- libdali_core now provides NVTX ranges functionality
- core is responsible for creating one DALI domain
- regular DALI code should use DomainTimeRange from core lib
- plain TimeRange is still header-only and should be used only
  for the development

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

JanuszL commented Nov 16, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1803930]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1803930]: BUILD PASSED

@@ -80,7 +81,8 @@ class DataReader : public Operator<Backend> {
// perform the prefetching operation
virtual void Prefetch() {
// We actually prepare the next batch
TimeRange tr("DataReader::Prefetch #" + to_string(curr_batch_producer_), TimeRange::kRed);
DomainTimeRange tr("[DALI] DataReader::Prefetch #" + to_string(curr_batch_producer_),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make them

Suggested change
DomainTimeRange tr("[DALI] DataReader::Prefetch #" + to_string(curr_batch_producer_),
DomainTimeRange tr("[DALI][DataReader] Prefetch #" + to_string(curr_batch_producer_),

and so on?

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 31 to 37
nvtxEventAttributes_t att = {};
att.version = NVTX_VERSION;
att.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
att.colorType = NVTX_COLOR_ARGB;
att.color = rgb | 0xff000000;
att.messageType = NVTX_MESSAGE_TYPE_ASCII;
att.message.ascii = name.c_str();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe deduplicate filling the attributes?
But I don't know if it's worth, maybe until it doesn't need to diverge, we can put it in the base class?

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 Nov 17, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1805949]: BUILD STARTED

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

JanuszL commented Nov 17, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1805976]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1805976]: BUILD PASSED

Copy link
Contributor

@klecki klecki left a comment

Choose a reason for hiding this comment

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

Looks ok, apart maybe from the stylistic choice of using RangeBase for colors.

A nice followup would be some .rst mentioning existence of those ranges.

// perform an initial buffer fill if it hasn't already happened
if (!initial_buffer_filled_) {
TimeRange tr("[Loader] Filling initial buffer", TimeRange::kBlue1);
DomainTimeRange tr("[DALI][Loader] Filling initial buffer", RangeBase::kBlue1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, my only nitpick would be that we use RangeBase instead of DomainTimeRange::kBlue... directly.

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 {

inline void FillAtrbs(nvtxEventAttributes_t &att, const std::string &name, const uint32_t rgb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a free function and not something in the base class?

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 Nov 17, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1806284]: BUILD STARTED

static const uint32_t kGreen1 = 0x859900;
static const uint32_t knvGreen = 0x76B900;

inline void FillAtrbs(nvtxEventAttributes_t &att, const std::string &name, const uint32_t rgb) {
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 void FillAtrbs(nvtxEventAttributes_t &att, const std::string &name, const uint32_t rgb) {
inline void FillAtrbs(nvtxEventAttributes_t &att, const char *name, const uint32_t rgb) {

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

};

struct DomainTimeRange : RangeBase {
explicit DomainTimeRange(const std::string &name, const uint32_t rgb = kBlue);
Copy link
Contributor

Choose a reason for hiding this comment

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

An overload with a const char *name would be welcome - we really don't have to create std::strings each time we enter a time range.

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


// Basic timerange for profiling
struct TimeRange : RangeBase {
TimeRange(const std::string name, const uint32_t rgb = kBlue) { // NOLINT
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
TimeRange(const std::string name, const uint32_t rgb = kBlue) { // NOLINT
TimeRange(const std::string &name, const uint32_t rgb = kBlue) : TimeRange(name.c_str(), rgb) {} // NOLINT
TimeRange(const char *name, const uint32_t rgb = kBlue) { // NOLINT

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

};
#endif

static DomainTimeRangeImpl range_impl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't compile without NVTX_ENABLED. BTW, perhaps it would be better to make it a signleton? Now we're initializing the object at load time - do we really want that (as opposed to initialize on first use)?

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


bool started = false;
};

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
#if NTXT_ENABLED

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

explicit DomainTimeRange(const std::string &name, const uint32_t rgb = kBlue);
~DomainTimeRange();
};

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
#else
struct DomainTimeRange : RangeBase {
using RangeBase::RangeBase;
};
#endif

^^^ this would avoid the costly call to a DLL-exported function when not using NVTX.

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

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1806284]: BUILD PASSED

@JanuszL
Copy link
Contributor Author

JanuszL commented Nov 18, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1810072]: BUILD STARTED

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

JanuszL commented Nov 18, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1810187]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1810187]: BUILD PASSED

@JanuszL JanuszL merged commit dc4bc35 into NVIDIA:master Nov 18, 2020
@JanuszL JanuszL deleted the rework_nvtx branch November 18, 2020 14:50
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

4 participants