Title: [248096] trunk/Source/WebCore
Revision
248096
Author
[email protected]
Date
2019-07-31 22:17:42 -0700 (Wed, 31 Jul 2019)

Log Message

[WHLSL] Replace memsetZero function with inline "= { }" code
https://bugs.webkit.org/show_bug.cgi?id=200328

Reviewed by Robin Morisset.

This is a ~20ms metal compile time improvement on compute_boids.

* Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
(WebCore::WHLSL::Metal::FunctionDefinitionWriter::FunctionDefinitionWriter):
(WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
* Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
(WebCore::WHLSL::Metal::writeNativeFunction):
* Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248095 => 248096)


--- trunk/Source/WebCore/ChangeLog	2019-08-01 04:24:57 UTC (rev 248095)
+++ trunk/Source/WebCore/ChangeLog	2019-08-01 05:17:42 UTC (rev 248096)
@@ -1,3 +1,19 @@
+2019-07-31  Saam Barati  <[email protected]>
+
+        [WHLSL] Replace memsetZero function with inline "= { }" code
+        https://bugs.webkit.org/show_bug.cgi?id=200328
+
+        Reviewed by Robin Morisset.
+
+        This is a ~20ms metal compile time improvement on compute_boids.
+
+        * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
+        (WebCore::WHLSL::Metal::FunctionDefinitionWriter::FunctionDefinitionWriter):
+        (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
+        * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
+        (WebCore::WHLSL::Metal::writeNativeFunction):
+        * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.h:
+
 2019-07-31  Andy Estes  <[email protected]>
 
         REGRESSION (r240942): first visually non-empty layout milestone is not reached in media documents until after the video finishes loading

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp (248095 => 248096)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp	2019-08-01 04:24:57 UTC (rev 248095)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp	2019-08-01 05:17:42 UTC (rev 248096)
@@ -91,18 +91,8 @@
         , m_functionMapping(functionMapping)
         , m_layout(layout)
     {
-        m_stringBuilder.flexibleAppend(
-            "template <typename T>\n"
-            "inline void ", memsetZeroFunctionName, "(thread T& value)\n"
-            "{\n"
-            "    thread char* ptr = static_cast<thread char*>(static_cast<thread void*>(&value));\n"
-            "    for (size_t i = 0; i < sizeof(T); ++i)\n"
-            "        ptr[i] = 0;\n"
-            "}\n");
     }
 
-    static constexpr const char* memsetZeroFunctionName = "memsetZero";
-
     virtual ~FunctionDefinitionWriter() = default;
 
     String toString() { return m_stringBuilder.toString(); }
@@ -217,7 +207,7 @@
 {
     auto iterator = m_functionMapping.find(&nativeFunctionDeclaration);
     ASSERT(iterator != m_functionMapping.end());
-    m_stringBuilder.append(writeNativeFunction(nativeFunctionDeclaration, iterator->value, m_intrinsics, m_typeNamer, memsetZeroFunctionName));
+    m_stringBuilder.append(writeNativeFunction(nativeFunctionDeclaration, iterator->value, m_intrinsics, m_typeNamer));
 }
 
 void FunctionDefinitionWriter::visit(AST::FunctionDefinition& functionDefinition)
@@ -594,7 +584,7 @@
         m_typeNamer.mangledNameForType(dereferenceExpression.pointer().resolvedType()), ' ', pointerName, " = ", right, ";\n",
         m_typeNamer.mangledNameForType(dereferenceExpression.resolvedType()), ' ', variableName, ";\n",
         "if (", pointerName, ") ", variableName, " = *", right, ";\n",
-        "else ", memsetZeroFunctionName, '(', variableName, ");\n"
+        "else ", variableName, " = { };\n"
     );
     appendLeftValue(dereferenceExpression, variableName, pointerName);
 }

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp (248095 => 248096)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-08-01 04:24:57 UTC (rev 248095)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-08-01 05:17:42 UTC (rev 248096)
@@ -120,7 +120,7 @@
     }
 }
 
-String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclaration, String& outputFunctionName, Intrinsics& intrinsics, TypeNamer& typeNamer, const char* memsetZeroFunctionName)
+String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclaration, String& outputFunctionName, Intrinsics& intrinsics, TypeNamer& typeNamer)
 {
     StringBuilder stringBuilder;
     if (nativeFunctionDeclaration.isCast()) {
@@ -129,8 +129,7 @@
         if (!nativeFunctionDeclaration.parameters().size()) {
             stringBuilder.flexibleAppend(
                 metalReturnName, ' ', outputFunctionName, "() {\n"
-                "    ", metalReturnName, " x;\n"
-                "    ", memsetZeroFunctionName, "(x);\n"
+                "    ", metalReturnName, " x = { };\n"
                 "    return x;\n"
                 "}\n"
             );

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.h (248095 => 248096)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.h	2019-08-01 04:24:57 UTC (rev 248095)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.h	2019-08-01 05:17:42 UTC (rev 248096)
@@ -45,7 +45,7 @@
 
 class TypeNamer;
 
-String writeNativeFunction(AST::NativeFunctionDeclaration&, String& outputFunctionName, Intrinsics&, TypeNamer&, const char* memsetZeroFunctionName);
+String writeNativeFunction(AST::NativeFunctionDeclaration&, String& outputFunctionName, Intrinsics&, TypeNamer&);
 
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to