aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/compile_cuda.py
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.ru>2022-02-10 16:45:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:49 +0300
commit7489e4682331202b9c7d863c0898eb83d7b12c2b (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /build/scripts/compile_cuda.py
parenta5950576e397b1909261050b8c7da16db58f10b1 (diff)
downloadydb-7489e4682331202b9c7d863c0898eb83d7b12c2b.tar.gz
Restoring authorship annotation for <somov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/compile_cuda.py')
-rw-r--r--build/scripts/compile_cuda.py118
1 files changed, 59 insertions, 59 deletions
diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py
index aaf9142b6d..c0bec50b2a 100644
--- a/build/scripts/compile_cuda.py
+++ b/build/scripts/compile_cuda.py
@@ -1,7 +1,7 @@
import sys
import subprocess
-import os
-import collections
+import os
+import collections
import re
import tempfile
@@ -13,52 +13,52 @@ def is_clang(command):
return False
-
-def main():
- try:
- sys.argv.remove('--y_skip_nocxxinc')
- skip_nocxxinc = True
- except ValueError:
- skip_nocxxinc = False
-
+
+def main():
+ try:
+ sys.argv.remove('--y_skip_nocxxinc')
+ skip_nocxxinc = True
+ except ValueError:
+ skip_nocxxinc = False
+
spl = sys.argv.index('--cflags')
mtime0 = sys.argv[1]
command = sys.argv[2: spl]
cflags = sys.argv[spl + 1:]
- dump_args = False
- if '--y_dump_args' in command:
- command.remove('--y_dump_args')
- dump_args = True
-
+ dump_args = False
+ if '--y_dump_args' in command:
+ command.remove('--y_dump_args')
+ dump_args = True
+
executable = command[0]
if not os.path.exists(executable):
print >> sys.stderr, '{} not found'.format(executable)
sys.exit(1)
- if is_clang(command):
+ if is_clang(command):
# nvcc concatenates the sources for clang, and clang reports unused
# things from .h files as if they they were defined in a .cpp file.
cflags += ['-Wno-unused-function', '-Wno-unused-parameter']
-
+
if not is_clang(command) and '-fopenmp=libomp' in cflags:
cflags.append('-fopenmp')
cflags.remove('-fopenmp=libomp')
-
+
skip_list = [
'-gline-tables-only',
# clang coverage
'-fprofile-instr-generate',
'-fcoverage-mapping',
'/Zc:inline', # disable unreferenced functions (kernel registrators) remove
- '-Wno-c++17-extensions',
- '-flto',
+ '-Wno-c++17-extensions',
+ '-flto',
'-faligned-allocation',
]
- if skip_nocxxinc:
- skip_list.append('-nostdinc++')
-
+ if skip_nocxxinc:
+ skip_list.append('-nostdinc++')
+
for flag in skip_list:
if flag in cflags:
cflags.remove(flag)
@@ -67,7 +67,7 @@ def main():
'-fsanitize=',
'-fsanitize-coverage=',
'-fsanitize-blacklist=',
- '--system-header-prefix',
+ '--system-header-prefix',
]
for prefix in skip_prefix_list:
cflags = [i for i in cflags if not i.startswith(prefix)]
@@ -83,49 +83,49 @@ def main():
cflags = filter(good, cflags)
cpp_args = []
- compiler_args = []
-
- # NVCC requires particular MSVC versions which may differ from the version
- # used to compile regular C++ code. We have a separate MSVC in Arcadia for
- # the CUDA builds and pass it's root in $Y_VC_Root.
- # The separate MSVC for CUDA may absent in Yandex Open Source builds.
- vc_root = os.environ.get('Y_VC_Root')
-
- cflags_queue = collections.deque(cflags)
- while cflags_queue:
-
- arg = cflags_queue.popleft()
+ compiler_args = []
+
+ # NVCC requires particular MSVC versions which may differ from the version
+ # used to compile regular C++ code. We have a separate MSVC in Arcadia for
+ # the CUDA builds and pass it's root in $Y_VC_Root.
+ # The separate MSVC for CUDA may absent in Yandex Open Source builds.
+ vc_root = os.environ.get('Y_VC_Root')
+
+ cflags_queue = collections.deque(cflags)
+ while cflags_queue:
+
+ arg = cflags_queue.popleft()
if arg == '-mllvm':
compiler_args.append(arg)
compiler_args.append(cflags_queue.popleft())
continue
if arg[:2].upper() in ('-I', '/I', '-B'):
- value = arg[2:]
- if not value:
- value = cflags_queue.popleft()
+ value = arg[2:]
+ if not value:
+ value = cflags_queue.popleft()
if arg[1] == 'I':
cpp_args.append('-I{}'.format(value))
elif arg[1] == 'B': # todo: delete "B" flag check when cuda stop to use gcc
pass
continue
-
- match = re.match(r'[-/]D(.*)', arg)
- if match:
- define = match.group(1)
- # We have C++ flags configured for the regular C++ build.
- # There is Y_MSVC_INCLUDE define with a path to the VC header files.
- # We need to change the path accordingly when using a separate MSVC for CUDA.
- if vc_root and define.startswith('Y_MSVC_INCLUDE'):
- define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root))
- cpp_args.append('-D' + define.replace('\\', '/'))
+
+ match = re.match(r'[-/]D(.*)', arg)
+ if match:
+ define = match.group(1)
+ # We have C++ flags configured for the regular C++ build.
+ # There is Y_MSVC_INCLUDE define with a path to the VC header files.
+ # We need to change the path accordingly when using a separate MSVC for CUDA.
+ if vc_root and define.startswith('Y_MSVC_INCLUDE'):
+ define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root))
+ cpp_args.append('-D' + define.replace('\\', '/'))
continue
-
+
compiler_args.append(arg)
-
+
command += cpp_args
if compiler_args:
command += ['--compiler-options', ','.join(compiler_args)]
-
+
# --keep is necessary to prevent nvcc from embedding nvcc pid in generated
# symbols. It makes nvcc use the original file name as the prefix in the
# generated files (otherwise it also prepends tmpxft_{pid}_00000000-5), and
@@ -142,11 +142,11 @@ def main():
os.environ['TZ'] = 'UTC0' # POSIX fixed offset format.
os.environ['TZDIR'] = '/var/empty' # Against counterfeit /usr/share/zoneinfo/$TZ.
- if dump_args:
- sys.stdout.write('\n'.join(command))
- else:
+ if dump_args:
+ sys.stdout.write('\n'.join(command))
+ else:
sys.exit(subprocess.Popen(command, stdout=sys.stderr, stderr=sys.stderr, cwd='/').wait())
-
-
-if __name__ == '__main__':
- main()
+
+
+if __name__ == '__main__':
+ main()