Skip to content

Assorted meson fixes #1491

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

Merged
merged 4 commits into from
Jan 20, 2021
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
54 changes: 31 additions & 23 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ if get_option('build_backends')
## Tensorflow
## ~~~~~~~~~~
tf_dl_lib = cc.find_library('dl', required: false)
tf_tensorflow_cc_lib = dependency('tensorflow_cc',
required: false, include_type:'system')
# We had `is_system: true` to reduce warnings, but meson > 0.56.0 breaks.
tf_tensorflow_cc_lib = dependency('tensorflow_cc', required: false)
if get_option('tensorflow') and tf_dl_lib.found() and tf_tensorflow_cc_lib.found()
deps += [tf_dl_lib, tf_tensorflow_cc_lib]
files += 'src/neural/network_tf_cc.cc'
Expand Down Expand Up @@ -278,7 +278,7 @@ if get_option('build_backends')
ispc_extra_args += ['--pic']
outputnames = [ '@[email protected]']
if not ispc_native_only
outputnames += ['@BASENAME@_sse2.o', '@BASENAME@_sse4.o',
outputnames += ['@BASENAME@_sse2.o', '@BASENAME@_sse4.o',
'@BASENAME@_avx.o', '@BASENAME@_avx2.o',
'@BASENAME@_avx512knl.o', '@BASENAME@_avx512skx.o' ]
endif
Expand Down Expand Up @@ -441,6 +441,11 @@ if get_option('build_backends')
if get_option('nvcc_ccbin') != ''
cuda_arguments += ['-ccbin=' + get_option('nvcc_ccbin')]
endif
cuda_cc = get_option('cc_cuda') # Unfortunately option cuda_cc is reserved.
nvcc_extra_args = []
if cuda_cc != ''
nvcc_extra_args = ['-arch=compute_' + cuda_cc, '-code=sm_' + cuda_cc]
endif
foreach x : get_option('cudnn_include')
cuda_arguments += ['-I', x]
endforeach
Expand All @@ -454,37 +459,42 @@ if get_option('build_backends')
arguments: cuda_arguments,
)
files += cuda_files
files += cuda_gen.process(cuda_files_nvcc_common)
nvcc_extra_args = ['-arch=compute_70']
files += cuda_gen.process(cuda_files_nvcc_common, extra_args: nvcc_extra_args)
nvcc_arch = '-arch=compute_70'
nvcc_sm_list = ['sm_80', 'sm_75', 'sm_86', 'sm_70']
if host_machine.system() != 'windows'
nvcc_extra_args = ['-arch=compute_60']
nvcc_arch = '-arch=compute_60'
nvcc_sm_list += ['sm_60']
if host_machine.cpu_family() == 'arm'
if ['arm', 'aarch64'].contains(host_machine.cpu_family())
# Add Jetson versions to the list.
nvcc_extra_args = ['-arch=compute_53']
message('Jetson support enabled.')
nvcc_arch = '-arch=compute_53'
nvcc_sm_list += ['sm_72', 'sm_62', 'sm_53']
endif
endif
nvcc_help = run_command(nvcc, '-h').stdout()
foreach x : nvcc_sm_list
if nvcc_help.contains(x)
nvcc_extra_args += '-code=' + x
endif
endforeach
# Ignore the given CC for fp16 when it is not in the supported list.
if cuda_cc == '' or not nvcc_sm_list.contains('sm_' + cuda_cc)
nvcc_extra_args = [nvcc_arch]
nvcc_help = run_command(nvcc, '-h').stdout()
foreach x : nvcc_sm_list
if nvcc_help.contains(x)
nvcc_extra_args += '-code=' + x
endif
endforeach
endif
files += cuda_gen.process(cuda_files_nvcc_fp16, extra_args: nvcc_extra_args)
has_backends = true
endif

## ~~~~~~~~
## DirectX
## ~~~~~~~~
# we should always be able to build DirectX12 backend on windows platform

# we should always be able to build DirectX12 backend on windows platform
if host_machine.system() == 'windows' and get_option('dx')
dx_d3d12 = cc.find_library('d3d12')
dx_dxgi = cc.find_library('dxgi')

dx_files = [
'src/neural/dx/network_dx.cc',
'src/neural/dx/shader_wrapper.cc',
Expand All @@ -497,8 +507,7 @@ if get_option('build_backends')
subdir('src/neural/dx/shaders')

has_backends = true
endif

endif

endif # if get_option('build_backends')

Expand Down Expand Up @@ -588,12 +597,11 @@ if get_option('gtest')
include_directories: includes, link_with: lc0_lib, dependencies: gtest
), args: '--gtest_output=xml:syzygy.xml', timeout: 90)

test('EncodePositionForNN',
test('EncodePositionForNN',
executable('encoder_test', 'src/neural/encoder_test.cc', pb_files,
include_directories: includes, link_with: lc0_lib,
dependencies: [gtest]
), args: '--gtest_output=xml:encoder.xml', timeout: 90)

endif


Expand All @@ -606,7 +614,7 @@ if get_option('python_bindings')
python = pymod.find_installation('python3')
if python.language_version() < '3.7'
error('You need python 3.7 or newer')
endif
endif
py_bindings_generator = find_program('scripts/gen_py_bindings.py')

gen_py_bindings = custom_target('backends', input:[], output:['backends.cc'],
Expand Down
7 changes: 6 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ option('dnnl_dir',
value: '',
description: 'Paths to DNNL install directory')

option('cudnn_include',
option('cudnn_include',
type: 'array',
value: ['/opt/cuda/include/', '/usr/local/cuda/include/', '/usr/lib/cuda/include/'],
description: 'Paths to cudnn include directory')
Expand Down Expand Up @@ -137,3 +137,8 @@ option('python_bindings',
type: 'boolean',
value: false,
description: 'Build Python bindings for the python to bind.')

option('cc_cuda',
type: 'string',
value: '',
description: 'Build for a specific cuda CC, e.g. -Dcc_cuda=35 for CC 3.5')