1# Copyright 2016 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6# Recipe for Skia skpbench. 7 8 9import calendar 10 11 12DEPS = [ 13 'flavor', 14 'recipe_engine/context', 15 'recipe_engine/file', 16 'recipe_engine/path', 17 'recipe_engine/platform', 18 'recipe_engine/properties', 19 'recipe_engine/python', 20 'recipe_engine/raw_io', 21 'recipe_engine/step', 22 'recipe_engine/time', 23 'run', 24 'vars', 25] 26 27ADB_BINARY = 'adb.1.0.35' 28 29 30def _run(api, title, *cmd, **kwargs): 31 with api.context(cwd=api.path['start_dir'].join('skia')): 32 return api.run(api.step, title, cmd=list(cmd), **kwargs) 33 34 35def _adb(api, title, *cmd, **kwargs): 36 if 'infra_step' not in kwargs: 37 kwargs['infra_step'] = True 38 return _run(api, title, ADB_BINARY, *cmd, **kwargs) 39 40 41def skpbench_steps(api): 42 """benchmark Skia using skpbench.""" 43 is_vulkan = 'Vulkan' in api.vars.builder_name 44 is_metal = 'Metal' in api.vars.builder_name 45 is_android = 'Android' in api.vars.builder_name 46 is_apple_m1 = 'AppleM1' in api.vars.builder_name 47 is_all_paths_volatile = 'AllPathsVolatile' in api.vars.builder_name 48 is_mskp = 'Mskp' in api.vars.builder_name 49 is_ddl = 'DDL' in api.vars.builder_name 50 is_9x9 = '9x9' in api.vars.builder_name 51 52 api.file.ensure_directory( 53 'makedirs perf_dir', api.flavor.host_dirs.perf_data_dir) 54 55 if is_android: 56 app = api.vars.build_dir.join('skpbench') 57 _adb(api, 'push skpbench', 'push', app, api.flavor.device_dirs.bin_dir) 58 59 skpbench_dir = api.vars.workdir.join('skia', 'tools', 'skpbench') 60 table = api.path.join(api.vars.swarming_out_dir, 'table') 61 62 if is_vulkan: 63 config = 'vk' 64 elif is_metal: 65 config = 'mtl' 66 elif is_android: 67 config = 'gles' 68 else: 69 config = 'gl' 70 71 internal_samples = 4 if is_android or is_apple_m1 else 8 72 73 if is_all_paths_volatile: 74 config = "%smsaa%i" % (config, internal_samples) 75 76 skpbench_invocation = api.path.join(api.flavor.device_dirs.bin_dir, 'skpbench') 77 78 # skbug.com/10184 79 if is_vulkan and 'GalaxyS20' in api.vars.builder_name: 80 skpbench_invocation = "LD_LIBRARY_PATH=/data/local/tmp %s" % skpbench_invocation 81 82 skpbench_args = [ 83 skpbench_invocation, 84 '--resultsfile', table, 85 '--config', config, 86 '--internalSamples', str(internal_samples), 87 # TODO(dogben): Track down what's causing bots to die. 88 '-v5'] 89 if is_ddl: 90 skpbench_args += ['--ddl'] 91 # disable the mask generation threads for simplicity's sake in DDL mode 92 skpbench_args += ['--gpuThreads', '0'] 93 if is_9x9: 94 skpbench_args += [ 95 '--ddlNumRecordingThreads', 9, 96 '--ddlTilingWidthHeight', 3] 97 if is_android: 98 skpbench_args += [ 99 '--adb', 100 '--adb_binary', ADB_BINARY] 101 if is_mskp: 102 skpbench_args += [api.flavor.device_dirs.mskp_dir] 103 elif is_all_paths_volatile: 104 skpbench_args += [ 105 '--allPathsVolatile', 106 '--suffix', "_volatile", 107 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_*svg.skp'), 108 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_motionmark*.skp'), 109 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_chalkboard.skp')] 110 else: 111 skpbench_args += [api.flavor.device_dirs.skp_dir] 112 113 if api.properties.get('dont_reduce_ops_task_splitting') == 'true': 114 skpbench_args += ['--dontReduceOpsTaskSplitting'] 115 116 if api.properties.get('gpu_resource_cache_limit'): 117 skpbench_args += ['--gpuResourceCacheLimit', api.properties.get('gpu_resource_cache_limit')] 118 119 api.run(api.python, 'skpbench', 120 script=skpbench_dir.join('skpbench.py'), 121 args=skpbench_args) 122 123 skiaperf_args = [ 124 table, 125 '--properties', 126 'gitHash', api.properties['revision'], 127 ] 128 if api.vars.is_trybot: 129 skiaperf_args.extend([ 130 'issue', api.vars.issue, 131 'patchset', api.vars.patchset, 132 'patch_storage', api.vars.patch_storage, 133 ]) 134 135 skiaperf_args.extend(['swarming_bot_id', api.vars.swarming_bot_id]) 136 skiaperf_args.extend(['swarming_task_id', api.vars.swarming_task_id]) 137 138 now = api.time.utcnow() 139 ts = int(calendar.timegm(now.utctimetuple())) 140 json_path = api.path.join( 141 api.flavor.host_dirs.perf_data_dir, 142 'skpbench_%s_%d.json' % (api.properties['revision'], ts)) 143 144 skiaperf_args.extend([ 145 '--outfile', json_path 146 ]) 147 148 skiaperf_args.append('--key') 149 for k in sorted(api.vars.builder_cfg.keys()): 150 if not k in ['configuration', 'role', 'is_trybot']: 151 skiaperf_args.extend([k, api.vars.builder_cfg[k]]) 152 153 api.run(api.python, 'Parse skpbench output into Perf json', 154 script=skpbench_dir.join('skiaperf.py'), 155 args=skiaperf_args) 156 157 158def RunSteps(api): 159 api.vars.setup() 160 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) 161 162 # The app_name passed to api.flavor.setup() is used to determine which app 163 # to install on an attached device. That work is done in skpbench_steps, so 164 # we pass None here. 165 api.flavor.setup(None) 166 167 try: 168 mksp_mode = ('Mskp' in api.vars.builder_name) 169 api.flavor.install(skps=not mksp_mode, mskps=mksp_mode) 170 skpbench_steps(api) 171 finally: 172 api.flavor.cleanup_steps() 173 api.run.check_failure() 174 175 176TEST_BUILDERS = [ 177 'Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-All-Android_Skpbench_Mskp', 178 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_AllPathsVolatile_Skpbench', 179 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_Vulkan_AllPathsVolatile_Skpbench', 180 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench', 181 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench_DDLTotal_9x9', 182 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-AllPathsVolatile_Skpbench', 183 'Perf-Mac11-Clang-MacMini9.1-GPU-AppleM1-arm64-Release-All-Metal_AllPathsVolatile_Skpbench', 184] 185 186 187def GenTests(api): 188 for builder in TEST_BUILDERS: 189 test = ( 190 api.test(builder) + 191 api.properties(buildername=builder, 192 revision='abc123', 193 path_config='kitchen', 194 swarm_out_dir='[SWARM_OUT_DIR]') + 195 api.path.exists( 196 api.path['start_dir'].join('skia'), 197 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets', 198 'skp', 'VERSION'), 199 ) + 200 api.step_data('get swarming bot id', 201 stdout=api.raw_io.output('skia-bot-123')) + 202 api.step_data('get swarming task id', 203 stdout=api.raw_io.output('123456')) 204 ) 205 if 'Win' in builder: 206 test += api.platform('win', 64) 207 yield test 208 209 b = ('Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-' 210 'Android_Vulkan_Skpbench') 211 yield ( 212 api.test('trybot') + 213 api.properties(buildername=b, 214 revision='abc123', 215 path_config='kitchen', 216 swarm_out_dir='[SWARM_OUT_DIR]', 217 dont_reduce_ops_task_splitting='true', 218 gpu_resource_cache_limit='16777216') + 219 api.path.exists( 220 api.path['start_dir'].join('skia'), 221 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets', 222 'skp', 'VERSION'), 223 ) + 224 api.step_data('get swarming bot id', 225 stdout=api.raw_io.output('skia-bot-123')) + 226 api.step_data('get swarming task id', 227 stdout=api.raw_io.output('123456')) + 228 api.properties(patch_storage='gerrit') + 229 api.properties.tryserver( 230 buildername=b, 231 gerrit_project='skia', 232 gerrit_url='https://skia-review.googlesource.com/', 233 ) 234 ) 235