[WHLSL] Add compile time flag to dump metal compile times
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Aug 2019 23:17:48 +0000 (23:17 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Aug 2019 23:17:48 +0000 (23:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200447

Reviewed by Myles C. Maxfield.

* Modules/webgpu/WHLSL/WHLSLPrepare.h:
* platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
(WebCore::trySetFunctions):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::trySetFunctions):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248277 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h
Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

index 766fb2f..11f45d9 100644 (file)
@@ -1,3 +1,16 @@
+2019-08-05  Saam Barati  <sbarati@apple.com>
+
+        [WHLSL] Add compile time flag to dump metal compile times
+        https://bugs.webkit.org/show_bug.cgi?id=200447
+
+        Reviewed by Myles C. Maxfield.
+
+        * Modules/webgpu/WHLSL/WHLSLPrepare.h:
+        * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
+        (WebCore::trySetFunctions):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::trySetFunctions):
+
 2019-08-05  Chris Dumez  <cdumez@apple.com>
 
         navigator.geolocation wrapper should not become GC-collectable once its frame is detached
index 3366436..2191632 100644 (file)
@@ -36,6 +36,8 @@ namespace WebCore {
 
 namespace WHLSL {
 
+constexpr bool dumpMetalCompileTimes = false;
+
 struct RenderPrepareResult {
     String metalSource;
     Metal::MangledFunctionName mangledVertexEntryPointName;
index 5474820..667f7fb 100644 (file)
@@ -34,6 +34,8 @@
 #import "WHLSLPrepare.h"
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
+#import <wtf/DataLog.h>
+#import <wtf/MonotonicTime.h>
 #import <wtf/text/StringConcatenate.h>
 
 namespace WebCore {
@@ -85,7 +87,12 @@ static Optional<WHLSL::ComputeDimensions> trySetFunctions(const GPUPipelineStage
         NSError *error = nil;
 
         BEGIN_BLOCK_OBJC_EXCEPTIONS;
+        MonotonicTime startTime;
+        if (WHLSL::dumpMetalCompileTimes)
+            startTime = MonotonicTime::now();
         computeLibrary = adoptNS([device.platformDevice() newLibraryWithSource:whlslCompileResult->metalSource options:nil error:&error]);
+        if (WHLSL::dumpMetalCompileTimes)
+            dataLogLn("Metal compile times: ", (MonotonicTime::now() - startTime).milliseconds(), " ms");
         END_BLOCK_OBJC_EXCEPTIONS;
 #ifndef NDEBUG
         if (!computeLibrary)
index a545a1a..2c37df6 100644 (file)
@@ -37,7 +37,9 @@
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/CheckedArithmetic.h>
+#import <wtf/DataLog.h>
 #import <wtf/HashSet.h>
+#import <wtf/MonotonicTime.h>
 #import <wtf/OptionSet.h>
 #import <wtf/Optional.h>
 #import <wtf/text/StringConcatenate.h>
@@ -397,7 +399,12 @@ static bool trySetFunctions(const GPUPipelineStageDescriptor& vertexStage, const
         NSError *error = nil;
 
         BEGIN_BLOCK_OBJC_EXCEPTIONS;
+        MonotonicTime startTime;
+        if (WHLSL::dumpMetalCompileTimes)
+            startTime = MonotonicTime::now();
         vertexLibrary = adoptNS([device.platformDevice() newLibraryWithSource:whlslCompileResult->metalSource options:nil error:&error]);
+        if (WHLSL::dumpMetalCompileTimes)
+            dataLogLn("Metal compile times: ", (MonotonicTime::now() - startTime).milliseconds(), " ms");
         END_BLOCK_OBJC_EXCEPTIONS;
 
         if (!vertexLibrary && error) {