Skip to content

[SYCL-PTX] Add a JSON backend for the ProgModel builtin #1781

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

Closed
wants to merge 9 commits into from

Conversation

Naghasan
Copy link
Contributor

This add the generator used to create the spirv_builtin.h in #1712

Add a JSON output for the ClangProgModelBuiltinEmitter.

This patch also include header generator for libclc that consumes the JSON ouput,
which gets automatically trigged on changes on the SPIRVBuiltins.td.

Signed-off-by: Victor Lomuller [email protected]

Copy link
Contributor

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

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

didn't look particularly close, but comments on the approach.

}

std::string JSONBuiltinInterfaceEmitter::TypeDesc::GetBaseTypeAsStr() const {
if (Name == "void") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use curleys for single line if/else/etc. Applies through this patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it? I see some below as well as here still.

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, BTW I can't find where the coding style mention this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently it is just something that has been enforced forever without having ever been put into the document! I'm likely going to add it to the document to be consistent with what reviewers enforce.

void JSONBuiltinInterfaceEmitter::Emit() {

// Parse the Records to populate the internal lists.
GetOverloads();
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect calling these directly is against the original author's abstraction (which is why they were private in the first place). How do other emitters handle this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no other emitter

@Naghasan Naghasan force-pushed the victor/json-builtins branch 3 times, most recently from 31fcbc3 to a2d8392 Compare June 1, 2020 11:05
// Size of the element in bits.
int Size;
// Is a integer.
bool IsInteger;
Copy link
Contributor

Choose a reason for hiding this comment

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

The hope is that it would be more readable as well as more consistent with the rest of clang code.

}

std::string JSONBuiltinInterfaceEmitter::TypeDesc::GetBaseTypeAsStr() const {
if (Name == "void") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it? I see some below as well as here still.


if (Ty->isSubClassOf("GenericType")) {
assert(!Expansion.size() && "Types already expanded");
auto NVec = Ty->getValueAsDef("VectorList")->getValueAsListOfInts("List");
Copy link
Contributor

Choose a reason for hiding this comment

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

Throughout the patch, you're using 'auto' in cases that the coding standard prohibits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@Naghasan Naghasan force-pushed the victor/json-builtins branch from a2d8392 to 591043a Compare June 1, 2020 17:42
Naghasan added 7 commits June 2, 2020 11:50
Add a JSON output for the ClangProgModelBuiltinEmitter.
This patch also include header generator for libclc that consumes the JSON ouput,
which gets automatically trigged on changes on the SPIRVBuiltins.td.

Signed-off-by: Victor Lomuller <[email protected]>
… rather than directly in type emission.

Signed-off-by: Victor Lomuller <[email protected]>
Signed-off-by: Victor Lomuller <[email protected]>
Signed-off-by: Victor Lomuller <[email protected]>
Signed-off-by: Victor Lomuller <[email protected]>
@Naghasan Naghasan force-pushed the victor/json-builtins branch from 2851cbc to 90ba58a Compare June 2, 2020 11:54
IsPointer(T->getValueAsBit("IsPointer")),
IsConst(T->getValueAsBit("IsConst")),
IsVolatile(T->getValueAsBit("IsVolatile")) {
assert((!T->getValueAsBit("IsInteger") || !T->getValueAsBit("IsFloat")) &&
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 add the isSubClassOf checks as well? It seems that it shouldn't be a BUILTIN either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is already handled by the unreachable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is. I'm talking about a type that IsInteger, IsFloat, and isSubClassOf(FundamentalType) AND isSubClassOf(VectorType).

At the moment you catch only isInteger and isFloat, but if you leave any of those off it isnt.

Additionally, the logic below allows a type to be both a fundamental and vector type.

IsPointer(T->getValueAsBit("IsPointer")),
IsConst(T->getValueAsBit("IsConst")),
IsVolatile(T->getValueAsBit("IsVolatile")) {
assert((!T->getValueAsBit("IsInteger") || !T->getValueAsBit("IsFloat")) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is. I'm talking about a type that IsInteger, IsFloat, and isSubClassOf(FundamentalType) AND isSubClassOf(VectorType).

At the moment you catch only isInteger and isFloat, but if you leave any of those off it isnt.

Additionally, the logic below allows a type to be both a fundamental and vector type.

});
assert(SignatureLenIt.begin() != SignatureLenIt.end());
// Find out how many overloads this signature holds.
size_t NbOverload = 1;
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
size_t NbOverload = 1;
size_t NbOverload = *std::max_element(std::begin(SignatureLenIt), std::end(SignatureLenIt));

Comment on lines +1025 to +1026
std::vector<long int> NVec =
Ty->getValueAsDef("VectorList")->getValueAsListOfInts("List");
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay.
Out internal pre-commit check failed to build this patch on Windows with the following message:

clang\utils\TableGen\ClangProgModelBuiltinEmitter.cpp(1026): error C2440: 'initializing': cannot convert from 'std::vector<int64_t,std::allocator<_Ty>>' to 'std::vector<long,std::allocator<_Ty>>'
         with
         [
             _Ty=int64_t
         ]
         and
         [
             _Ty=long
         ]
clang\utils\TableGen\ClangProgModelBuiltinEmitter.cpp(1026): note: No constructor could take the source type, or constructor overload resolution was ambiguous

Copy link
Contributor

Choose a reason for hiding this comment

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

On Windows, "long" is 32 bit, so int64_t is long long. This likely should be std::vector<int64_t> instead.

@github-actions github-actions bot added the Stale label Feb 18, 2022
@github-actions github-actions bot closed this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants