forked from LeelaChessZero/lc0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request LeelaChessZero#4 from LeelaChessZero/master
merge
- Loading branch information
Showing
57 changed files
with
3,596 additions
and
2,528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import os | ||
if len(sys.argv) > 1 and os.path.isdir(sys.argv[1]): | ||
exit(0) | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,8 @@ else | |
protobuf_dep = protobuf_lib | ||
endif | ||
protoc = find_program('protoc', required : false) | ||
if not protobuf_dep.found() or not protoc.found() | ||
# For tensorflow skip system protobuf, chances are it will not work. | ||
if not protobuf_dep.found() or not protoc.found() or get_option('tensorflow') | ||
deps += subproject('protobuf').get_variable('protobuf_dep') | ||
protoc = subproject('protobuf').get_variable('protoc') | ||
else | ||
|
@@ -81,6 +82,7 @@ files += [ | |
'src/neural/factory.cc', | ||
'src/neural/loader.cc', | ||
'src/neural/network_check.cc', | ||
'src/neural/network_legacy.cc', | ||
'src/neural/network_mux.cc', | ||
'src/neural/network_random.cc', | ||
'src/neural/network_st_batch.cc', | ||
|
@@ -98,6 +100,7 @@ files += [ | |
'src/utils/random.cc', | ||
'src/utils/string.cc', | ||
'src/utils/transpose.cc', | ||
'src/utils/weights_adapter.cc', | ||
] | ||
includes += include_directories('src') | ||
|
||
|
@@ -152,6 +155,8 @@ if get_option('build_backends') | |
## Blas | ||
## ~~~~~ | ||
|
||
shared_files = [] | ||
|
||
has_blas = false | ||
|
||
accelerate_lib = dependency('Accelerate', required: false) | ||
|
@@ -165,7 +170,7 @@ if get_option('build_backends') | |
openblas_lib = cc.find_library('openblas', dirs: openblas_libdirs, required: false) | ||
endif | ||
|
||
if get_option('blas') or get_option('opencl') | ||
if get_option('blas') | ||
if get_option('mkl') and mkl_lib.found() | ||
add_project_arguments('-DUSE_MKL', language : 'cpp') | ||
includes += include_directories(get_option('mkl_include')) | ||
|
@@ -201,14 +206,6 @@ if get_option('build_backends') | |
has_blas = true | ||
endif | ||
|
||
if has_blas | ||
blas_files = [ | ||
'src/neural/blas/batchnorm.cc', | ||
'src/neural/blas/fully_connected_layer.cc', | ||
'src/neural/blas/winograd_convolution3.cc' | ||
] | ||
endif | ||
|
||
ispc = find_program('ispc', required: false) | ||
ispc_extra_args = [] | ||
if has_blas and get_option('ispc') and ispc.found() | ||
|
@@ -247,9 +244,18 @@ if get_option('build_backends') | |
|
||
if get_option('blas') and has_blas | ||
|
||
blas_files += [ | ||
blas_files = [ | ||
'src/neural/blas/convolution1.cc', | ||
'src/neural/blas/network_blas.cc' | ||
'src/neural/blas/fully_connected_layer.cc', | ||
'src/neural/blas/se_unit.cc', | ||
'src/neural/blas/network_blas.cc', | ||
'src/neural/blas/winograd_convolution3.cc' | ||
] | ||
|
||
shared_files = [ | ||
'src/neural/shared/activation.cc', | ||
'src/neural/shared/batchnorm.cc', | ||
'src/neural/shared/winograd_filter.cc', | ||
] | ||
|
||
files += blas_files | ||
|
@@ -284,29 +290,28 @@ if get_option('build_backends') | |
|
||
endif | ||
|
||
|
||
if get_option('opencl') and has_opencl | ||
|
||
if has_blas | ||
opencl_files = [ | ||
opencl_files = [ | ||
'src/neural/opencl/network_opencl.cc', | ||
'src/neural/opencl/OpenCL.cc', | ||
'src/neural/opencl/OpenCLTuner.cc', | ||
'src/neural/opencl/network_opencl.cc', | ||
] | ||
'src/neural/opencl/OpenCLBuffers.cc', | ||
] | ||
|
||
if not get_option('blas') | ||
opencl_files += blas_files | ||
endif | ||
shared_files = [ | ||
'src/neural/shared/activation.cc', | ||
'src/neural/shared/batchnorm.cc', | ||
'src/neural/shared/winograd_filter.cc', | ||
] | ||
|
||
includes += include_directories(get_option('opencl_include')) | ||
files += opencl_files | ||
has_backends = true | ||
else | ||
warning('The OpenCL backend requires a BLAS library') | ||
endif | ||
includes += include_directories(get_option('opencl_include')) | ||
files += opencl_files | ||
has_backends = true | ||
|
||
endif | ||
|
||
files += shared_files | ||
|
||
## ~~~~~ | ||
## cuDNN | ||
|
@@ -316,32 +321,54 @@ if get_option('build_backends') | |
cu_dnn = cc.find_library('cudnn', dirs: cudnn_libdirs, required: false) | ||
cu_dart = cc.find_library('cudart', dirs: cudnn_libdirs, required: false) | ||
nvcc = find_program('/usr/local/cuda/bin/nvcc', 'nvcc', required: false) | ||
|
||
#.cc files | ||
cuda_files = [ | ||
'src/neural/network_cudnn.cu', | ||
'src/neural/cuda/network_cudnn.cc', | ||
'src/neural/cuda/layers.cc', | ||
] | ||
|
||
# .cu files compiled without any specific sm version | ||
cuda_files_nvcc_common = [ | ||
'src/neural/cuda/common_kernels.cu', | ||
] | ||
|
||
# .cu files compiled with sm_70 (volta+). Only used by cudnn-fp16 | ||
cuda_files_nvcc_fp16 = [ | ||
'src/neural/cuda/fp16_kernels.cu', | ||
] | ||
|
||
if get_option('cudnn') and cu_blas.found() and cu_dnn.found() and cu_dart.found() and nvcc.found() | ||
deps += [cu_blas, cu_dnn, cu_dart] | ||
cuda_arguments = ['-c', '@INPUT@', '-o', '@OUTPUT@', | ||
'-I', meson.current_source_dir() + '/src'] | ||
if host_machine.system() == 'windows' | ||
cuda_arguments += ['-Xcompiler', '-MD'] | ||
else | ||
cuda_arguments += ['--std=c++14', '-Xcompiler', '-fPIC'] | ||
endif | ||
foreach x : get_option('cudnn_include') | ||
cuda_arguments += ['-I', x] | ||
endforeach | ||
if host_machine.system() == 'windows' | ||
outputname = '@[email protected]' | ||
else | ||
outputname = '@[email protected]' | ||
endif | ||
cuda_gen = generator(nvcc, | ||
output: outputname, | ||
arguments: cuda_arguments, | ||
) | ||
files += cuda_gen.process(cuda_files) | ||
foreach d : get_option('cudnn_include') | ||
if run_command('checkdir.py', d).returncode() == 0 | ||
includes += include_directories(d) | ||
endif | ||
endforeach | ||
includes += include_directories('src/neural/cuda/') | ||
|
||
cuda_arguments = ['@EXTRA_ARGS@', '-c', '@INPUT@', '-o', '@OUTPUT@', | ||
'-I', meson.current_source_dir() + '/src'] | ||
if host_machine.system() == 'windows' | ||
cuda_arguments += ['-Xcompiler', '-MD'] | ||
else | ||
cuda_arguments += ['--std=c++14', '-Xcompiler', '-fPIC'] | ||
endif | ||
foreach x : get_option('cudnn_include') | ||
cuda_arguments += ['-I', x] | ||
endforeach | ||
if host_machine.system() == 'windows' | ||
outputname = '@[email protected]' | ||
else | ||
outputname = '@[email protected]' | ||
endif | ||
cuda_gen = generator(nvcc, | ||
output: outputname, | ||
arguments: cuda_arguments, | ||
) | ||
files += cuda_files | ||
files += cuda_gen.process(cuda_files_nvcc_common) | ||
files += cuda_gen.process(cuda_files_nvcc_fp16, extra_args: ['-arch=compute_70', '-code=sm_70']) | ||
has_backends = true | ||
endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.