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

[SYCL][ESIMD] Introduce rdtsc API #12315

Merged
merged 5 commits into from
Jan 10, 2024
Merged

[SYCL][ESIMD] Introduce rdtsc API #12315

merged 5 commits into from
Jan 10, 2024

Conversation

fineg74
Copy link
Contributor

@fineg74 fineg74 commented Jan 6, 2024

No description provided.

@fineg74 fineg74 requested a review from a team as a code owner January 6, 2024 02:08
Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

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

I finished the 1st code-review pass. Please see the comments.

{"srnd", {"srnd", {a(0), a(1)}}}};
{"srnd", {"srnd", {a(0), a(1)}}},
{"timestamp",{"timestamp",{}}},
{"sr0",{"sr0",{}}}};
Copy link
Contributor

Choose a reason for hiding this comment

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

  • src0 has more info, the upper elements (2xI32 of 4) could be useful too.
  • sr0 is very machine specific (return is varied depending on GPU) it gets more info in newer GPUs
    let's drop support of sr0 for a while, until we know better how it is going to be used.

sycl/test-e2e/ESIMD/rdtsc_sr0.cpp Outdated Show resolved Hide resolved
Comment on lines 75 to 82

int TestResult = 0;

TestResult |= test_rdtsc_sr0();

if (!TestResult) {
std::cout << "Pass" << std::endl;
}
Copy link
Contributor

@v-klochkov v-klochkov Jan 8, 2024

Choose a reason for hiding this comment

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

nit: it could be shorter without extra-spaces and braces:

Suggested change
int TestResult = 0;
TestResult |= test_rdtsc_sr0();
if (!TestResult) {
std::cout << "Pass" << std::endl;
}
int TestFailed = test_rdtsc_sr0();
if (!TestFailed)
std::cout << "Pass" << std::endl;

Copy link
Contributor

Choose a reason for hiding this comment

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

can you please remove extra space too?

@fineg74 fineg74 changed the title [SYCL][ESIMD] Introduce rdtsc and sr0 API [SYCL][ESIMD] Introduce rdtsc API Jan 8, 2024
VectorOutputSR0.begin());
// Check if returned values are positive
Result |= std::any_of(VectorOutputRDTSC.begin(), VectorOutputRDTSC.end(),
[](uint64_t v) { return v <= 0; });
Copy link
Contributor

Choose a reason for hiding this comment

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

if v is unsigned, then how it can be less than zero?
The VectorOutputRDTSC needs to be signed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it will be signed there will be risk of overflow. I reworked the logic to reduce the chances of overflow

Copy link
Contributor

Choose a reason for hiding this comment

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

If suppose 2Ghz, then 2 secs = 32-bit. the timestamp returns 64-bit, which is huge (2 sec * 4Bil, so, there was no risk of overflow). The updated solution is good, except it needs 1 minor fix to avoid DCE-ing the load between rdtsc calls.

uint64_t StartCounter = sycl::ext::intel::experimental::esimd::rdtsc();
simd<uint64_t, 1> VectorResultRDTSC(VectorOutputRDTSCPtr + Idx);
uint64_t EndCounter = sycl::ext::intel::experimental::esimd::rdtsc();
VectorResultRDTSC = EndCounter > StartCounter;
Copy link
Contributor

Choose a reason for hiding this comment

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

because the original result of the load at L45 is not used, it may be deleted.
You can update L47 this way:

Suggested change
VectorResultRDTSC = EndCounter > StartCounter;
VectorResultRDTSC += EndCounter > StartCounter;

@@ -1723,6 +1723,13 @@ __ESIMD_API std::enable_if_t<__ESIMD_DNS::is_esimd_scalar<T>::value &&
return __ESIMD_NS::bfn<FuncControl>(src0, src1, src2);
}

/// rdtsc - get the value of rdtsc register.
Copy link
Contributor

Choose a reason for hiding this comment

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

rdtsc stands for ReaD TimeStamp Counter (I think). Can you please make it more clear in the comment here?

Copy link
Contributor

Choose a reason for hiding this comment

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

GenX returns 4 integers (which is probably the content of the drtsc register (if it is a register).
The function only returns uint64 (part of what GenX can return), please don't use the word register in this decription.

@v-klochkov v-klochkov merged commit 1261e05 into intel:sycl Jan 10, 2024
11 checks passed
@fineg74 fineg74 deleted the rdtsc branch January 10, 2024 21:41
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.

2 participants