diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 77eb00c64f..1600d10144 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -39,9 +39,13 @@ jobs: run: | cmake --preset default --fresh -DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM -DCMAKE_COMPILE_WARNING_AS_ERROR=false cmake --workflow --preset release + - uses: actions/checkout@v3 + with: + repository: 'shader-slang/MDL-SDK' + path: 'external/MDL-SDK' - name: Run benchmark run: | cd tools/benchmark + cp ../../external/MDL-SDK/examples/mdl_sdk/dxr/content/slangified/*.slang . pip install prettytable argparse - Copy-Item -Path C:\slang-benchmarks -Destination . -Recurse - python compile.py --samples 16 --target dxil --ci + python compile.py --samples 1 --target dxil diff --git a/tools/benchmark/compile.py b/tools/benchmark/compile.py index 0d995636dc..6717d33778 100644 --- a/tools/benchmark/compile.py +++ b/tools/benchmark/compile.py @@ -19,26 +19,20 @@ def clear_mkdir(dir): clear_mkdir('targets') clear_mkdir('targets/generated') -target_choices = ['spirv', 'spirv-glsl', 'dxil', 'dxil-embedded'] +target_choices = [ + 'spirv', # SPIRV directly + 'spirv-glsl', # SPIRV through synthesized GLSL + 'dxil', # DXIL with HLSL and DXC + 'dxil-embedded' # DXIL with precompiled modules +] parser = argparse.ArgumentParser() parser.add_argument('--target', type=str, default='spirv', choices=target_choices) parser.add_argument('--samples', type=int, default=1) parser.add_argument('--output', type=str, default='benchmarks.json') -parser.add_argument('--ci', action='store_true') args = parser.parse_args(sys.argv[1:]) -repo = 'slang-benchmarks' -if args.ci: - repo = 'C:\\slang-benchmarks' - -if not os.path.exists(repo): - repo = 'ssh://git@gitlab-master.nvidia.com:12051/slang/slang-benchmarks.git' - command = f'git clone {repo}' - subprocess.check_output(command) - -dxc = 'dxc.exe' slangc = '..\\..\\build\\Release\\bin\\slangc.exe' target = args.target samples = args.samples @@ -110,67 +104,55 @@ def compile_cmd(file, output, stage=None, entry=None, emit=False): if emit: cmd += f' -target {target_ext}' output += '.' + target_ext + if target == 'dxil-embedded': + cmd += ' -profile lib_6_6' elif embed: cmd += ' -embed-dxil' - cmd += ' -profile lib_6_6' - cmd += ' -incomplete-library' cmd += f' -o {output}' return cmd +### Monolithic compilation ### + +hit = 'hit.slang' + +cmd = compile_cmd(hit, f'targets/dxr-ch-mono', stage='closesthit', entry='MdlRadianceClosestHitProgram', emit=True) +run(cmd, f'full/{target_ext}/mono/closesthit') +print(f'[I] compiled shadow (monolithic)') + +cmd = compile_cmd(hit, f'targets/dxr-ah-mono', stage='anyhit', entry='MdlRadianceAnyHitProgram', emit=True) +run(cmd, f'full/{target_ext}/mono/anyhit') +print(f'[I] compiled shadow (monolithic)') + +cmd = compile_cmd(hit, f'targets/dxr-sh-mono', stage='anyhit', entry='MdlShadowAnyHitProgram', emit=True) +run(cmd, f'full/{target_ext}/mono/shadow') +print(f'[I] compiled shadow (monolithic)') + ### Module precompilation ### modules = [] -for file in glob.glob(f'{repo}\\mdl\\*.slang'): - if file.endswith('hit.slang'): - run(compile_cmd(file, 'modules/closesthit.slang-module', stage='closesthit'), 'module/closesthit') - run(compile_cmd(file, 'modules/anyhit.slang-module', stage='anyhit'), 'module/anyhit') - run(compile_cmd(file, 'modules/shadow.slang-module', stage='anyhit', entry='shadow'), 'module/shadow') - else: +for file in glob.glob(f'*.slang'): + if not file.endswith('hit.slang'): basename = os.path.basename(file) run(compile_cmd(file, f'modules/{basename}-module'), 'module/' + file) - modules.append(f'modules/{basename}-module') - - print(f'[I] compiled {file}.') + print(f'[I] compiled {file}.') -### Entrypoint compilation ### -hit = 'slang-benchmarks/mdl/hit.slang' -files = ' '.join(modules) +### Module whole compilation ### -# Module -cmd = compile_cmd(f'{files} modules/closesthit.slang-module', f'targets/dxr-ch-modules', stage='closesthit', emit=True) +cmd = compile_cmd(hit, f'targets/dxr-ch-modules', stage='closesthit', entry='MdlRadianceClosestHitProgram', emit=True) run(cmd, f'full/{target_ext}/module/closesthit') - print(f'[I] compiled closesthit (module)') -cmd = compile_cmd(f'{files} modules/anyhit.slang-module', f'targets/dxr-ah-modules', stage='anyhit', emit=True) +cmd = compile_cmd(hit, f'targets/dxr-ah-modules', stage='anyhit', entry='MdlRadianceAnyHitProgram', emit=True) run(cmd, f'full/{target_ext}/module/anyhit') - print(f'[I] compiled anyhit (module)') -cmd = compile_cmd(f'{files} modules/shadow.slang-module', f'targets/dxr-sh-modules', stage='anyhit', entry='shadow', emit=True) +cmd = compile_cmd(hit, f'targets/dxr-sh-modules', stage='anyhit', entry='MdlShadowAnyHitProgram', emit=True) run(cmd, f'full/{target_ext}/module/shadow') - print(f'[I] compiled shadow (module)') -# Monolithic -cmd = compile_cmd(hit, f'targets/dxr-ch-mono', stage='closesthit', emit=True) -run(cmd, f'full/{target_ext}/mono/closesthit') - -print(f'[I] compiled shadow (monolithic)') - -cmd = compile_cmd(hit, f'targets/dxr-ah-mono', stage='anyhit', emit=True) -run(cmd, f'full/{target_ext}/mono/anyhit') - -print(f'[I] compiled shadow (monolithic)') - -cmd = compile_cmd(hit, f'targets/dxr-sh-mono', stage='anyhit', entry='shadow', emit=True) -run(cmd, f'full/{target_ext}/mono/shadow') - -print(f'[I] compiled shadow (monolithic)') - # Module precompilation time precompilation_time = 0 for k in timings: