2016-02-17 19:05:18 +03:00
|
|
|
# -*- Python -*-
|
|
|
|
|
import os
|
|
|
|
|
import platform
|
|
|
|
|
import re
|
|
|
|
|
import subprocess
|
2019-03-06 19:26:05 +03:00
|
|
|
import struct
|
2016-02-17 19:05:18 +03:00
|
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
|
import lit.util
|
|
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
2018-12-12 17:05:01 +03:00
|
|
|
site_cfg = lit_config.params.get('site_config', None)
|
|
|
|
|
lit_config.load_config(config, site_cfg)
|
2016-02-17 19:05:18 +03:00
|
|
|
|
2019-10-15 14:20:23 +03:00
|
|
|
config.excludes = ['cmdparser.hpp']
|
|
|
|
|
config.excludes.append('spatial_batch_norm_op.h')
|
|
|
|
|
config.excludes.append('common_cudnn.h')
|
|
|
|
|
|
|
|
|
|
delimiter = "===============================================================";
|
|
|
|
|
print(delimiter)
|
2019-03-06 19:26:05 +03:00
|
|
|
print("CUDA " + config.cuda_version + " - will be used for testing")
|
|
|
|
|
print("LLVM " + config.llvm_version + " - will be used for testing")
|
|
|
|
|
print(platform.machine() + " - Platform architecture")
|
|
|
|
|
print(platform.system() + " " + platform.release() + " - Platform OS")
|
|
|
|
|
print(str(config.pointer_size * 8) + " - hipify-clang binary bitness")
|
|
|
|
|
print(str(struct.calcsize("P") * 8) + " - python " + str(platform.python_version()) + " binary bitness")
|
2019-10-15 14:20:23 +03:00
|
|
|
print(delimiter)
|
|
|
|
|
warns = None
|
|
|
|
|
if not config.cuda_dnn_root:
|
|
|
|
|
config.excludes.append('cudnn_convolution_forward.cu')
|
|
|
|
|
config.excludes.append('cudnn_softmax.cu')
|
|
|
|
|
print("WARN: cuDNN tests are excluded due to unset CUDA_DNN_ROOT_DIR")
|
|
|
|
|
warns = True
|
|
|
|
|
if not config.cuda_cub_root:
|
|
|
|
|
config.excludes.append('cub_01.cu')
|
2019-10-20 20:03:18 +03:00
|
|
|
config.excludes.append('cub_02.cu')
|
|
|
|
|
config.excludes.append('cub_03.cu')
|
2019-10-15 14:20:23 +03:00
|
|
|
print("WARN: CUB tests are excluded due to unset CUDA_CUB_ROOT_DIR")
|
|
|
|
|
warns = True
|
|
|
|
|
if warns:
|
|
|
|
|
print(delimiter)
|
2018-01-29 18:33:47 +03:00
|
|
|
|
2019-01-04 01:32:30 +03:00
|
|
|
if config.cuda_version_major == 7 and config.cuda_version_minor == 0:
|
|
|
|
|
config.excludes.append('headers_test_09.cu')
|
2019-01-22 22:26:43 +03:00
|
|
|
config.excludes.append('cudnn_convolution_forward.cu')
|
2019-01-03 18:06:49 +03:00
|
|
|
if config.cuda_version_major < 8:
|
|
|
|
|
config.excludes.append('cuSPARSE_02.cu')
|
2018-12-12 17:05:01 +03:00
|
|
|
if config.cuda_version_major < 9:
|
2018-12-11 22:03:11 +03:00
|
|
|
config.excludes.append('cuSPARSE_04.cu')
|
|
|
|
|
config.excludes.append('cuSPARSE_05.cu')
|
|
|
|
|
config.excludes.append('cuSPARSE_06.cu')
|
|
|
|
|
config.excludes.append('cuSPARSE_07.cu')
|
2019-01-03 18:06:49 +03:00
|
|
|
config.excludes.append('benchmark_curand_kernel.cpp')
|
2018-12-12 17:05:01 +03:00
|
|
|
if config.cuda_version_major < 10:
|
2018-11-30 15:33:57 +03:00
|
|
|
config.excludes.append('cuSPARSE_08.cu')
|
2018-12-04 19:24:29 +03:00
|
|
|
config.excludes.append('cuSPARSE_09.cu')
|
|
|
|
|
config.excludes.append('cuSPARSE_10.cu')
|
|
|
|
|
config.excludes.append('cuSPARSE_11.cu')
|
2018-11-30 15:33:57 +03:00
|
|
|
|
2019-08-28 21:17:35 +03:00
|
|
|
if config.llvm_version_major < 10:
|
|
|
|
|
config.excludes.append('pp_if_else_conditionals_LLVM_10.cu')
|
|
|
|
|
config.excludes.append('pp_if_else_conditionals_01_LLVM_10.cu')
|
|
|
|
|
|
2018-12-12 17:05:01 +03:00
|
|
|
# name: The name of this test suite.
|
|
|
|
|
config.name = 'hipify'
|
|
|
|
|
|
|
|
|
|
# suffixes: CUDA source is only supported
|
|
|
|
|
config.suffixes = ['.cu','.cuh','.cpp','.c','.hpp','.h']
|
|
|
|
|
|
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
|
|
|
|
config.test_format = lit.formats.ShTest()
|
|
|
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
2018-12-11 22:03:11 +03:00
|
|
|
|
2016-02-17 19:05:18 +03:00
|
|
|
# test_exec_root: The path where tests are located (default is the test suite root).
|
|
|
|
|
#config.test_exec_root = config.test_source_root
|
|
|
|
|
|
|
|
|
|
# target_triple: Used by ShTest and TclTest formats for XFAIL checks.
|
|
|
|
|
config.target_triple = '(unused)'
|
|
|
|
|
|
|
|
|
|
# available_features: Used by ShTest and TclTest formats for REQUIRES checks.
|
|
|
|
|
config.available_features = []
|
|
|
|
|
|
|
|
|
|
obj_root = getattr(config, 'obj_root', None)
|
|
|
|
|
if obj_root is not None:
|
|
|
|
|
config.test_exec_root = obj_root
|
|
|
|
|
|
|
|
|
|
if obj_root is not None:
|
|
|
|
|
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
|
|
|
|
|
if not llvm_tools_dir:
|
|
|
|
|
lit_config.fatal('No LLVM tools dir set!')
|
|
|
|
|
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
|
|
|
|
|
config.environment['PATH'] = path
|
|
|
|
|
|
2018-01-09 20:20:28 +03:00
|
|
|
hipify_path = obj_root
|
|
|
|
|
|
2019-01-09 20:18:36 +03:00
|
|
|
clang_arguments = "-v"
|
2018-01-09 20:20:28 +03:00
|
|
|
if sys.platform in ['win32']:
|
|
|
|
|
run_test_ext = ".bat"
|
|
|
|
|
hipify_path += "/" + config.build_type
|
2019-10-14 11:55:55 +03:00
|
|
|
# CUDA SDK ROOT
|
2019-01-09 20:18:36 +03:00
|
|
|
clang_arguments += " -isystem'%s'/common/inc"
|
2018-01-09 20:20:28 +03:00
|
|
|
else:
|
|
|
|
|
run_test_ext = ".sh"
|
2019-10-14 11:55:55 +03:00
|
|
|
# CUDA SDK ROOT
|
2019-01-09 20:18:36 +03:00
|
|
|
clang_arguments += " -isystem'%s'/samples/common/inc"
|
2019-03-06 19:26:05 +03:00
|
|
|
if config.pointer_size == 8:
|
|
|
|
|
clang_arguments += " -D__LP64__"
|
2018-01-09 20:20:28 +03:00
|
|
|
|
2019-10-21 15:51:25 +03:00
|
|
|
# Set max clang's CudaArch for corresponding CUDA version
|
|
|
|
|
# to support maximum CUDA features in offline tests
|
|
|
|
|
if config.cuda_version_major == 7:
|
2019-10-21 17:50:00 +03:00
|
|
|
if config.cuda_version_minor == 5:
|
|
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_53"
|
|
|
|
|
else:
|
|
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_52"
|
|
|
|
|
elif config.cuda_version_major == 8:
|
2019-10-21 15:51:25 +03:00
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_62"
|
2019-10-21 17:50:00 +03:00
|
|
|
elif config.cuda_version_major == 9:
|
|
|
|
|
if config.cuda_version_minor == 2:
|
|
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_72"
|
|
|
|
|
else:
|
|
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_70"
|
|
|
|
|
elif config.cuda_version_major == 10:
|
2019-10-21 15:51:25 +03:00
|
|
|
clang_arguments += " --cuda-gpu-arch=sm_75"
|
|
|
|
|
|
2019-10-15 14:20:23 +03:00
|
|
|
# cuDNN ROOT
|
|
|
|
|
if config.cuda_dnn_root:
|
|
|
|
|
clang_arguments += " -I'%s'/include"
|
2019-10-14 11:55:55 +03:00
|
|
|
# CUB ROOT
|
2019-10-15 14:20:23 +03:00
|
|
|
if config.cuda_cub_root:
|
|
|
|
|
clang_arguments += " -I'%s'"
|
|
|
|
|
|
|
|
|
|
if config.cuda_dnn_root and config.cuda_cub_root:
|
|
|
|
|
config.substitutions.append(("%clang_args", clang_arguments % (config.cuda_sdk_root, config.cuda_dnn_root, config.cuda_cub_root)))
|
|
|
|
|
elif config.cuda_dnn_root:
|
|
|
|
|
config.substitutions.append(("%clang_args", clang_arguments % (config.cuda_sdk_root, config.cuda_dnn_root)))
|
|
|
|
|
elif config.cuda_cub_root:
|
|
|
|
|
config.substitutions.append(("%clang_args", clang_arguments % (config.cuda_sdk_root, config.cuda_cub_root)))
|
|
|
|
|
else:
|
|
|
|
|
config.substitutions.append(("%clang_args", clang_arguments % config.cuda_sdk_root))
|
2019-10-14 11:55:55 +03:00
|
|
|
|
2019-10-20 20:08:56 +03:00
|
|
|
if config.llvm_version_major < 4:
|
|
|
|
|
hipify_arguments = "-I'%s'/include"
|
|
|
|
|
else:
|
|
|
|
|
hipify_arguments = "--cuda-path='%s'"
|
|
|
|
|
|
2019-10-15 14:20:23 +03:00
|
|
|
config.substitutions.append(("%hipify_args", hipify_arguments % config.cuda_root))
|
2018-01-09 20:20:28 +03:00
|
|
|
config.substitutions.append(("hipify", '"' + hipify_path + "/hipify-clang" + '"'))
|
|
|
|
|
config.substitutions.append(("%run_test", '"' + config.test_source_root + "/run_test" + run_test_ext + '"'))
|