Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Apr 27, 2025

Wrapping around because want to define _CrtDbgReport before crtdbg.h header is included. Defining variable templated _CrtDbgReport overrides the use of variable argument _CrtDbgReport function, that declared in crtdbg.h.

With variable argument _CrtDbgReport, llvm-spirv throws the following error:

UnsupportedVarArgFunction: Variadic functions other than 'printf' are not supported in SPIR-V.

Fixes CMPLRLLVM-66787


// Include real STL <array> header - the next one from the include search
// directories.
// Define variable templated _CrtDbgReport with MSVC to avoid the following
Copy link
Contributor

Choose a reason for hiding this comment

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

To me, that does not seem like a reliable solution. We still don't have control over the real <array> content and tomorrow it may start using some new error reporting mechanism which won't be covered by this.

I think that the proper way of not hitting issues like this from uncontrolled STL implementations is stop using them in our device headers.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to provide as much support for using STL in user's code as possible. Using it ourselves and making fixes like that is the best way to ensure the smoothest user experience possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to provide as much support for using STL in user's code as possible.

Do we document any guarantees anywhere? I'm not aware of any extensions and the core SYCL spec explicitly says that everything that is not documented is not guaranteed to be supported.

What is our plan for cases when MSVC headers are updated in an incompatible way in between our releases?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/C-CXX-StandardLibrary.rst and your argument applies to them as well. MSVC can change their implementation of any of the "documented/supported" APIs at any point.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/C-CXX-StandardLibrary.rst and your argument applies to them as well. MSVC can change their implementation of any of the "documented/supported" APIs at any point.

That is true, but the document explicitly only document a concrete subset of functions and 95% of them are implemented in the library. We do take a similar risk, but it is lower. And we have officially taken it by documenting the support.

Here we are somewhat in the gray area where we don't document the support for std::array, but still try to use it and jump through the hoops to make it work, but what's the point if we don't document it to be supported?

I think that we should either document it to justify those tricks, or just make our implementation more robust by explicitly saying that we won't support that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "gray area" is a feature and not a bug :) As for documenting, I'd prefer to do it once we are more confident that it actually works. So maybe implement this, use std::array internally, and if we don't have any bug reports for the next release, then document it as supported (i.e. treat the current state as "experimental").

Copy link
Contributor

Choose a reason for hiding this comment

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

As for documenting, I'd prefer to do it once we are more confident that it actually works.

And how do we ensure that? std::array has 20 different methods, do we use them all in our implementation to ensure that they work?

I still find our approach weird. If we want to support std::array, let's write dedicated tests for it and fix any bugs, but I'm not sure if it worth continue to use it in our own implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to provide as much support for using STL in user's code as possible. Using it ourselves and making fixes like that is the best way to ensure the smoothest user experience possible.

FYI: #18252

@uditagarwal97 uditagarwal97 changed the title [SYCL] Add STL wrapper for std::array and define _CrtDbgReport [SYCL] Add STL wrapper for crtdbg.h and define _CrtDbgReport Apr 28, 2025
Signed-off-by: Agarwal, Udit <udit.agarwal@intel.com>
@uditagarwal97 uditagarwal97 merged commit 17b287a into sycl Apr 29, 2025
36 of 38 checks passed
@uditagarwal97 uditagarwal97 deleted the udit/array_stl_wrapper branch April 29, 2025 00:28
@@ -1,16 +1,13 @@
// Test to isolate sycl::vec bug due to use of std::array in
// the constructor.
Copy link
Contributor

Choose a reason for hiding this comment

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

@uditagarwal97, I think the comment requires updates too.

// Test to isolate sycl::vec bug due to use of std::array in
// the constructor.

KornevNikita pushed a commit that referenced this pull request May 27, 2025
)

Wrapping around because want to define `_CrtDbgReport` before `crtdbg.h`
header is included. Defining variable templated `_CrtDbgReport`
overrides the use of variable argument `_CrtDbgReport` function, that
declared in `crtdbg.h`.

With variable argument `_CrtDbgReport`, `llvm-spirv` throws the
following error:
```
UnsupportedVarArgFunction: Variadic functions other than 'printf' are not supported in SPIR-V.
```
Fixes CMPLRLLVM-66787

---------

Signed-off-by: Agarwal, Udit <udit.agarwal@intel.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.

6 participants