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

Update crosstool_wrapper_driver_is_not_gcc #12

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-osx.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .ci_support/osx_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ MACOSX_DEPLOYMENT_TARGET:
c_compiler:
- clang
c_compiler_version:
- '13'
- '14'
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
cxx_compiler:
- clangxx
cxx_compiler_version:
- '13'
- '14'
macos_machine:
- x86_64-apple-darwin13.4.0
target_platform:
Expand Down
4 changes: 2 additions & 2 deletions .ci_support/osx_arm64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ MACOSX_DEPLOYMENT_TARGET:
c_compiler:
- clang
c_compiler_version:
- '13'
- '14'
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
cxx_compiler:
- clangxx
cxx_compiler_version:
- '13'
- '14'
macos_machine:
- arm64-apple-darwin20.0.0
target_platform:
Expand Down
3 changes: 2 additions & 1 deletion .circleci/config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion .scripts/build_steps.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .scripts/run_osx_build.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions build-locally.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 47 additions & 11 deletions recipe/bazel_toolchain/crosstool_wrapper_driver_is_not_gcc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -26,12 +26,20 @@ DESCRIPTION:
as is as a string to --compiler-options of nvcc. When "-x cuda" is not
present, this wrapper invokes hybrid_driver_is_not_gcc with the input
arguments as is.

NOTES:
Changes to the contents of this file must be propagated from
//third_party/gpus/crosstool/crosstool_wrapper_is_not_gcc to
//third_party/gpus/crosstool/v*/*/clang/bin/crosstool_wrapper_is_not_gcc
"""

# NOTE wolfv this file can be found here: https://raw.githubusercontent.com/tensorflow/tensorflow/master/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl
# NOTE updated: ngam: https://github.com/tensorflow/tensorflow/blob/v2.10.0-rc0/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl

from __future__ import print_function

__author__ = 'keveman@google.com (Manjunath Kudlur)'

from argparse import ArgumentParser
import os
import subprocess
Expand All @@ -47,6 +55,7 @@ NVCC_VERSION = '${CUDA_VERSION}'
NVCC_PATH = '${CUDA_HOME}/bin/nvcc'
PREFIX_DIR = os.path.dirname(GCC_HOST_COMPILER_PATH)


def Log(s):
print('gpus/crosstool: {0}'.format(s))

Expand Down Expand Up @@ -111,13 +120,15 @@ def GetHostCompilerOptions(argv):

return opts


def _update_options(nvcc_options):
if NVCC_VERSION in ("7.0",):
return nvcc_options

update_options = { "relaxed-constexpr" : "expt-relaxed-constexpr" }
return [ update_options[opt] if opt in update_options else opt
for opt in nvcc_options ]
update_options = {"relaxed-constexpr": "expt-relaxed-constexpr"}
return [update_options[opt] if opt in update_options else opt
for opt in nvcc_options]


def GetNvccOptions(argv):
"""Collect the -nvcc_options values from argv.
Expand All @@ -139,6 +150,7 @@ def GetNvccOptions(argv):
return ' '.join(['--'+a for a in options])
return ''


def system(cmd):
"""Invokes cmd with os.system().

Expand All @@ -155,6 +167,7 @@ def system(cmd):
else:
return -os.WTERMSIG(retv)


def InvokeNvcc(argv, log=False):
"""Call nvcc with arguments assembled from argv.

Expand All @@ -181,7 +194,13 @@ def InvokeNvcc(argv, log=False):
std_options = GetOptionValue(argv, '-std')
# Supported -std flags as of CUDA 9.0. Only keep last to mimic gcc/clang.
nvcc_allowed_std_options = ["c++03", "c++11", "c++14"]
std_options = ''.join([' -std=' + define
nvcc_std_map = {}
if int(NVCC_VERSION.split('.')[0]) >= 11:
nvcc_std_map["c++1z"] = "c++17"
nvcc_allowed_std_options += ["c++17", "c++1z"]
std_options = ''.join([' -std=' +
(nvcc_std_map[define]
if define in nvcc_std_map else define)
for define in std_options if define in nvcc_allowed_std_options][-1:])
fatbin_options = ''.join([' --fatbin-options=' + option
for option in GetOptionValue(argv, '-Xcuda-fatbinary')])
Expand Down Expand Up @@ -215,11 +234,21 @@ def InvokeNvcc(argv, log=False):
out = ' -o ' + out_file[0]

nvccopts = '-D_FORCE_INLINES '
for capability in GetOptionValue(argv, "--cuda-gpu-arch"):
capabilities_sm = set(GetOptionValue(argv, "--cuda-gpu-arch"))
capabilities_compute = set(GetOptionValue(argv, '--cuda-include-ptx'))
# When both "code=sm_xy" and "code=compute_xy" are requested for a single
# arch, they can be combined using "code=xy,compute_xy" which avoids a
# redundant PTX generation during compilation.
capabilities_both = capabilities_sm.intersection(capabilities_compute)
for capability in capabilities_both:
capability = capability[len('sm_'):]
nvccopts += r'-gencode=arch=compute_%s,code=\"sm_%s,compute_%s\" ' % (
capability, capability, capability)
for capability in capabilities_sm - capabilities_both:
capability = capability[len('sm_'):]
nvccopts += r'-gencode=arch=compute_%s,\"code=sm_%s\" ' % (capability,
capability)
for capability in GetOptionValue(argv, '--cuda-include-ptx'):
for capability in capabilities_compute - capabilities_both:
capability = capability[len('sm_'):]
nvccopts += r'-gencode=arch=compute_%s,\"code=compute_%s\" ' % (capability,
capability)
Expand All @@ -229,6 +258,8 @@ def InvokeNvcc(argv, log=False):
nvccopts += std_options
nvccopts += m_options
nvccopts += warning_options
# Force C++17 dialect (note, everything in just one string!)
nvccopts += ' --std c++17 '
nvccopts += fatbin_options

if depfiles:
Expand All @@ -239,7 +270,8 @@ def InvokeNvcc(argv, log=False):
' --compiler-bindir=' + GCC_HOST_COMPILER_PATH +
' -I .' +
' -x cu ' + opt + includes + ' ' + srcs + ' -M -o ' + depfile)
if log: Log(cmd)
if log:
Log(cmd)
exit_status = system(cmd)
if exit_status != 0:
return exit_status
Expand All @@ -253,7 +285,8 @@ def InvokeNvcc(argv, log=False):
# TODO(zhengxq): for some reason, 'gcc' needs this help to find 'as'.
# Need to investigate and fix.
cmd = 'PATH=' + PREFIX_DIR + ':$PATH ' + cmd
if log: Log(cmd)
if log:
Log(cmd)
return system(cmd)


Expand All @@ -264,9 +297,11 @@ def main():
args, leftover = parser.parse_known_args(sys.argv[1:])

if args.x and args.x[0] == 'cuda':
if args.cuda_log: Log('-x cuda')
if args.cuda_log:
Log('-x cuda')
leftover = [pipes.quote(s) for s in leftover]
if args.cuda_log: Log('using nvcc')
if args.cuda_log:
Log('using nvcc')
return InvokeNvcc(leftover, log=args.cuda_log)

# Strip our flags before passing through to the CPU compiler for files which
Expand All @@ -279,5 +314,6 @@ def main():

return subprocess.call([CPU_COMPILER] + cpu_compiler_flags)


if __name__ == '__main__':
sys.exit(main())
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "bazel-toolchain" %}
{% set version = "0.1.5" %}
{% set version = "0.2.0" %}


package:
Expand Down