Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated MDL shader sources for benchmarks #4965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
80 changes: 31 additions & 49 deletions tools/benchmark/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]: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
Expand Down Expand Up @@ -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:
Expand Down
Loading