<commit_before>#!/usr/bin/env python
# Copyright 2014 Nervana Systems Inc. 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.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Top-level control of the building/installation/cleaning of various targets

import optparse
import re
import os
import os.path
import subprocess
import pycuda.driver as drv
import pycuda.autoinit
from kernel_specs import get_ptx_file, kernels, sass_dir, ptx_dir, pre_dir, cubin_dir, dump_dir

p = optparse.OptionParser()
p.add_option("-k", "--kernels", action="store_true", dest="kernels", default=True,
             help="build or update all kernels (default)")
p.add_option("-c", "--clean", action="store_true", dest="clean",
             help="delete all generated files")
p.add_option("-p", "--preprocess", action="store_true", dest="preprocess",
             help="preprocess sass files only (for devel and debug)")
p.add_option("-d", "--dump", action="store_true", dest="dump",
             help="disassemble cubin files only (for devel and debug)")
p.add_option("-w", "--warn", action="store_true", dest="warn",
             help="enable warnings (for devel and debug)")
p.add_option("-j", "--max_concurrent", type="int", default=10,
             help="Concurrently launch a maximum of this many processes.")
p.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
             help="print output of nvcc calls.")
opts, args = p.parse_args()

if opts.preprocess or opts.dump:
    opts.kernels = False

attributes = drv.Context.get_device().get_attributes()
major = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MAJOR]
minor = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MINOR]

if major == 5 and minor == 3:
    arch = "sm_53"
else:
    arch = "sm_50"

ptxas_opts   = ["ptxas", "-arch " + arch ]
maxas_opts_i = ["maxas.pl", "-i"]
maxas_opts_p = ["maxas.pl", "-p"]
dump_opts    = ["nvdisasm", "-raw"]

if not opts.warn:<commit_msg>Default to SM 50 when no local working GPU is found.<commit_after>#!/usr/bin/env python
# Copyright 2014 Nervana Systems Inc. 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.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Top-level control of the building/installation/cleaning of various targets

import optparse
import re
import os
import os.path
import subprocess
import pycuda.driver as drv
from kernel_specs import get_ptx_file, kernels, sass_dir, ptx_dir, pre_dir, cubin_dir, dump_dir

p = optparse.OptionParser()
p.add_option("-k", "--kernels", action="store_true", dest="kernels", default=True,
             help="build or update all kernels (default)")
p.add_option("-c", "--clean", action="store_true", dest="clean",
             help="delete all generated files")
p.add_option("-p", "--preprocess", action="store_true", dest="preprocess",
             help="preprocess sass files only (for devel and debug)")
p.add_option("-d", "--dump", action="store_true", dest="dump",
             help="disassemble cubin files only (for devel and debug)")
p.add_option("-w", "--warn", action="store_true", dest="warn",
             help="enable warnings (for devel and debug)")
p.add_option("-j", "--max_concurrent", type="int", default=10,
             help="Concurrently launch a maximum of this many processes.")
p.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
             help="print output of nvcc calls.")
opts, args = p.parse_args()

if opts.preprocess or opts.dump:
    opts.kernels = False

try:
    import pycuda.autoinit
    attributes = drv.Context.get_device().get_attributes()
    major = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MAJOR]
    minor = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MINOR]
except:
    # No working local CUDA, default to 5,0
    major = 5
    minor = 0

if major == 5 and minor == 3:
    arch = "sm_53"
else:
    arch = "sm_50"

ptxas_opts   = ["ptxas", "-arch " + arch ]
maxas_opts_i = ["maxas.pl", "-i"]
maxas_opts_p = ["maxas.pl", "-p"]
dump_opts    = ["nvdisasm", "-raw"]

if not opts.warn:
{'fraction_non_alphanumeric': 0.12926535527900443, 'fraction_numerical': 0.0076274588518667205, 'mean_word_length': 4.08469387755102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298634', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1516, 'n_words': 504}