Bug 200748

Summary: [WHLSL] Make "operator cast" constructors native
Product: WebKit Reporter: Saam Barati <saam>
Component: WebGPUAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dino, ews-watchlist, fpizlo, jonlee, justin_fan, mmaxfield, rmorisset, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 200699    
Attachments:
Description Flags
patch
mmaxfield: review+
patch for landing none

Saam Barati
Reported 2019-08-14 18:49:11 PDT
...
Attachments
patch (32.64 KB, patch)
2019-08-16 17:47 PDT, Saam Barati
mmaxfield: review+
patch for landing (33.40 KB, patch)
2019-08-16 20:29 PDT, Saam Barati
no flags
Saam Barati
Comment 1 2019-08-16 17:32:22 PDT
patch forthcoming
Saam Barati
Comment 2 2019-08-16 17:47:09 PDT
EWS Watchlist
Comment 3 2019-08-16 17:49:31 PDT
Attachment 376571 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:169: Multi line control clauses should use braces. [whitespace/braces] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Myles C. Maxfield
Comment 4 2019-08-16 19:51:03 PDT
Comment on attachment 376571 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=376571&action=review > Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:140 > + return WTF::get<AST::ConstantExpression>(matrixType.typeArguments()[typeArgumentIndex]).integerLiteral().value(); Can we move this to Intrinsics? I don't think this is the only place where this kind of computation is performed. > Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:211 > + if (nativeFunctionDeclaration.parameters().size() == numRows) { > + // operator matrixMxN (vectorN, ..., vectorN) > + for (unsigned i = 0; i < numRows; ++i) { > + for (unsigned j = 0; j < numColumns; ++j) > + stringBuilder.flexibleAppend("x[", j * numRows + i, "] = ", args[i], "[", j, "];\n"); > + } > + > + } else { > + // operator matrixMxN (scalar, ..., scalar) > + unsigned index = 0; > + for (unsigned i = 0; i < numRows; ++i) { > + for (unsigned j = 0; j < numColumns; ++j) { > + stringBuilder.flexibleAppend("x[", j * numRows + i, "] = ", args[index], ";\n"); > + ++index; > + } > + } > + } Is there reason you're not just calling the MSL constructors because MSL and HLSL define their matrices with different major-ness? This is probably worth a comment. > Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:327 > + auto& result = downcast<AST::NativeTypeDeclaration>(downcast<AST::TypeReference>(downcast<AST::TypeDefinition>(typeReference.resolvedType()).type()).resolvedType()); Can this be shared with the lambda above?
Saam Barati
Comment 5 2019-08-16 19:56:26 PDT
Comment on attachment 376571 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=376571&action=review >> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:140 >> + return WTF::get<AST::ConstantExpression>(matrixType.typeArguments()[typeArgumentIndex]).integerLiteral().value(); > > Can we move this to Intrinsics? I don't think this is the only place where this kind of computation is performed. We should put it on NativeTypeDeclaration. >> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:327 >> + auto& result = downcast<AST::NativeTypeDeclaration>(downcast<AST::TypeReference>(downcast<AST::TypeDefinition>(typeReference.resolvedType()).type()).resolvedType()); > > Can this be shared with the lambda above? it could, but I don't think having more functions in this limited scenario is gonna make anything more clear.
Saam Barati
Comment 6 2019-08-16 20:29:42 PDT
Created attachment 376586 [details] patch for landing
WebKit Commit Bot
Comment 7 2019-08-16 21:13:12 PDT
Comment on attachment 376586 [details] patch for landing Clearing flags on attachment: 376586 Committed r248814: <https://trac.webkit.org/changeset/248814>
WebKit Commit Bot
Comment 8 2019-08-16 21:13:14 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 9 2019-08-16 21:14:18 PDT
Note You need to log in before you can comment on or make changes to this bug.