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 SYCL version check #989

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dklochkov-emb
Copy link

@dklochkov-emb dklochkov-emb commented Nov 18, 2024

Check of SYCL version was added according to agreement, see details:
KhronosGroup/SYCL-Docs#634

@dklochkov-emb dklochkov-emb requested a review from a team as a code owner November 18, 2024 15:46
@CLAassistant
Copy link

CLAassistant commented Nov 18, 2024

CLA assistant check
All committers have signed the CLA.

@@ -45,6 +45,7 @@ class TEST_NAME : public util::test_base {
#define TEST_FAIL
log.note("SYCL_LANGUAGE_VERSION not present");
#else
static_assert(SYCL_LANGUAGE_VERSION, "202012L");
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be something like:

static_assert(SYCL_LANGUAGE_VERSION == 202012L)

Followed by a check that the type is really long.

Copy link
Author

Choose a reason for hiding this comment

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

Agree, fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Followed by a check that the type is really long.

Something like:

static_assert(std::is_same_v<decltype(SYCL_LANGUAGE_VERSION), long>);

@@ -45,6 +45,7 @@ class TEST_NAME : public util::test_base {
#define TEST_FAIL
log.note("SYCL_LANGUAGE_VERSION not present");
#else
static_assert(SYCL_LANGUAGE_VERSION, "202012L");
log.note("SYCL_LANGUAGE_VERSION = %d", static_cast<int>(SYCL_LANGUAGE_VERSION));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this log message is still useful since we are now checking for a specific value.

Copy link
Author

Choose a reason for hiding this comment

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

As for me, we can remove this log message due to static_assert.

@dklochkov-emb
Copy link
Author

Ping

Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

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

Thanks.
By the way, it is better to write SYCL in uppercase everywhere, even in the commit messages.

@keryell keryell changed the title Add sycl version check Add SYCL version check Nov 23, 2024
@bader
Copy link
Contributor

bader commented Dec 5, 2024

@dklochkov-emb, please, address this feedback by fixing commit message. Alternatively, I can do it myself by squashing all commits with my own commit message.

Please, fix CI failures.

@tomdeakin
Copy link
Contributor

Please bump the DPC++ version in the CI to ensure this test doesn't fail.
Resolve AdaptiveCpp either by updating implementation, or disabling this test.

@psalz
Copy link
Contributor

psalz commented Dec 5, 2024

I realize this is not your fault, but the whole test setup used here is terribly outdated. The idiomatic way of writing this test would be something like

TEST_CASE("The implementation defines the correct SYCL_LANGUAGE_VERSION macro") {
#ifndef SYCL_LANGUAGE_VERSION
    FAIL("SYCL_LANGUAGE_VERSION is not defined");
#else
    STATIC_REQUIRE(std::is_same_v<decltype(SYCL_LANGUAGE_VERSION), long>);
    STATIC_REQUIRE(SYCL_LANGUAGE_VERSION == 202012L);
#endif
}

Edit: Actually, why does this check have to be a static assertion? Can't we just fail at runtime?

@illuhad
Copy link
Contributor

illuhad commented Dec 5, 2024

I've just aligned SYCL_LANGUAGE_VERSION in upstream AdaptiveCpp: AdaptiveCpp/AdaptiveCpp#1630
So if we update the CI image, the test should also work in AdaptiveCpp.

@dklochkov-emb dklochkov-emb force-pushed the sycl-version-definition-changes branch from cb45f28 to 6c7dac1 Compare December 11, 2024 11:10
@AlexeySachkov
Copy link
Contributor

Edit: Actually, why does this check have to be a static assertion? Can't we just fail at runtime?

The earlier you get an error, the better. When you work on a SYCL implementation and static assert fails, you immediately know where and what failed: most likely some of interfaces don't have correct signatures (like type of a macro-defined constant here).

However, when you run CTS, you probably also want to have a little check saying "yes, interfaces are correct" simply for having all checks reported at the same time and be a part of a final CTS validation report.

check2 allows to fully offload STATIC_REQUIRE to runtime phase via CATCH_CONFIG_RUNTIME_STATIC_REQUIRE. Perhaps that could be a default mode in which we run CI and do certification runs. Development could stay with compile-time reporting mode for shorter feedback loop.

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.

9 participants