SWDEV-299127 - Merge 'develop' into 'amd-staging'

Change-Id: I8f88c6dc3bc4e669d74b378c03ecd082907d4e27
Tento commit je obsažen v:
Jenkins
2021-12-21 14:33:32 -05:00
11 změnil soubory, kde provedl 140 přidání a 30 odebrání
+3 -3
Zobrazit soubor
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.16.8)
project(hiptests)
# Check if platform and compiler are set
if(HIP_PLATFORM STREQUAL "amd")
@@ -34,11 +33,10 @@ else()
cmake_path(SET CMAKE_C_COMPILER "${HIP_PATH}/bin/hipcc.bat")
endif()
if(NOT UNIX)
# In linux this reruns the cmake and fails with incorrect vars.
# so the project command is used only for windows
project(build_tests)
project(hiptests)
endif()
if(NOT DEFINED CATCH2_PATH)
@@ -76,6 +74,8 @@ include_directories(
${JSON_PARSER}
)
file(COPY ./hipTestMain/config DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/hipTestMain)
if(HIP_PLATFORM MATCHES "amd" AND HIP_COMPILER MATCHES "clang")
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
+8 -1
Zobrazit soubor
@@ -35,7 +35,14 @@ Some useful functions are:
This information can be accessed in any test via using: `TestContext::get().isAmd()`.
## Config file schema
Some tests can be skipped using a config file placed in same directory as the exe.
Some tests can be skipped using a config file placed in hipTestMain/config folder. Multiple config files can be defined for different configurations.
The naming convention for the file needs to be "config_platform_os_archname.json"
Platform and os are mandatory, "all" for os if the tests needs to be skipped for all OS.
Arch name is optional and takes precedence while loading the json file.
example:
config_amd_windows.json
config_nvidia_windows.json
The schema of the json file is as follows:
```json
+7 -4
Zobrazit soubor
@@ -169,9 +169,12 @@ function(catch_discover_tests TARGET)
VERBATIM
)
file(RELATIVE_PATH ctestincludepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_include_file})
file(RELATIVE_PATH ctestfilepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_tests_file})
file(WRITE "${ctest_include_file}"
"if(EXISTS \"${ctest_tests_file}\")\n"
" include(\"${ctest_tests_file}\")\n"
"if(EXISTS \"${ctestfilepath}\")\n"
" include(\"${ctestfilepath}\")\n"
"else()\n"
" message(WARNING \"Test ${TARGET} not built yet.\")\n"
"endif()\n"
@@ -180,14 +183,14 @@ function(catch_discover_tests TARGET)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
# Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
APPEND PROPERTY TEST_INCLUDE_FILES "${ctestincludepath}"
)
else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
if (NOT ${test_include_file_set})
set_property(DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
PROPERTY TEST_INCLUDE_FILE "${ctestincludepath}"
)
else()
message(FATAL_ERROR
+4 -3
Zobrazit soubor
@@ -107,12 +107,14 @@ foreach(line ${output})
string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name})
set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}")
endif()
file(RELATIVE_PATH exe_path ${CMAKE_CURRENT_BINARY_DIR} ${TEST_EXECUTABLE})
# ...and add to script
add_command(add_test
"${prefix}${test}${suffix}"
${TEST_EXECUTOR}
"${TEST_EXECUTABLE}"
"${exe_path}"
"${test_name}"
${extra_args}
"${reporter_arg}"
@@ -121,7 +123,6 @@ foreach(line ${output})
add_command(set_tests_properties
"${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}")
+28
Zobrazit soubor
@@ -0,0 +1,28 @@
{
"DisabledTests":
[
"Unit_hipMemcpy3D_Basic - int",
"Unit_hipMemcpy3D_Basic - unsigned int",
"Unit_hipMemcpy3D_Basic - float",
"Unit_hipMemcpy3DAsync_Basic - int",
"Unit_hipMemcpy3DAsync_Basic - unsigned int",
"Unit_hipMemcpy3DAsync_Basic - float",
"Unit_hipMemcpy3DAsync_multiDevice-Negative",
"Unit_hipMemcpy3DAsync_multiDevice-DiffStream",
"Unit_hipPointerGetAttributes_ClusterAlloc",
"Unit_hipMallocManaged_MultiChunkMultiDevice",
"Unit_hipMallocManaged_TwoPointers - int",
"Unit_hipMallocManaged_TwoPointers - float",
"Unit_hipMallocManaged_TwoPointers - double",
"Unit_hipMallocManaged_DeviceContextChange - unsigned char",
"Unit_hipMallocManaged_DeviceContextChange - int",
"Unit_hipMallocManaged_DeviceContextChange - float",
"Unit_hipMallocManaged_DeviceContextChange - double",
"Unit_hipHostMalloc_CoherentTst",
"Unit_hipMallocManaged_CoherentTst",
"Unit_hipMallocManaged_CoherentTstWthAdvise",
"Unit_hipMalloc_CoherentTst",
"Unit_hipExtMallocWithFlags_CoherentTst"
]
}
+73 -9
Zobrazit soubor
@@ -21,7 +21,79 @@ void TestContext::detectPlatform() {
#endif
}
std::string TestContext::substringFound(std::vector<std::string> list, std::string filename) {
std::string match = "";
for(unsigned int i = 0; i < list.size() ; i++) {
if (filename.find(list.at(i)) != std::string::npos) {
match = list.at(i);
break;
}
}
return match;
}
std::string TestContext::getMatchingConfigFile(std::string config_dir) {
std::string configFileToUse;
for(auto& p: fs::recursive_directory_iterator(config_dir)) {
fs::path filename = p.path();
std::string cur_arch = "TODO";
std::string arch = substringFound(amd_arch_list_,filename.filename().string());
std::string platform = substringFound(platform_list_,filename.filename().string());
std::string os = substringFound(os_list_,filename.filename().string());
// if arch found then use that exit from loop
if(arch == cur_arch) {
configFileToUse = filename.string();
break;
// match the platform/os and continue to look
} else if((platform == config_.platform) &&
(os == config_.os || os == "all")) {
configFileToUse = filename.string();
}
}
return configFileToUse;
}
std::string& TestContext::getJsonFile() {
fs::path config_dir = exe_path;
config_dir = config_dir.parent_path();
int levels = 0;
bool configFolderFound = false;
std::vector <std::string> configList;
std::string configFile;
// check a max of 5 levels down the executable path
while(levels < 5) {
fs::path temp_path = config_dir;
temp_path /= "hipTestMain";
temp_path /= "config";
if (fs::exists(temp_path)) {
config_dir = fs::absolute(temp_path);
configFolderFound = true;
break;
} else {
config_dir = config_dir.parent_path();
levels++;
}
}
// get config.json files if config folder.
if (configFolderFound) {
json_file_ = getMatchingConfigFile(config_dir.string());
}
return json_file_;
}
void TestContext::fillConfig() {
config_.platform = (amd ? "amd" : (nvidia ? "nvidia" : "unknown"));
config_.os = (p_windows ? "windows" : (p_linux ? "linux" : "unknown"));
if (config_.os == "unknown" || config_.platform == "unknown") {
LogPrintf("%s", "Either Config or Os is unknown, this wont end well");
abort();
}
const char* env_config = std::getenv("HT_CONFIG_FILE");
LogPrintf("Env Config file: %s",
(env_config != nullptr) ? env_config : "Not found, using default config");
@@ -41,17 +113,9 @@ void TestContext::fillConfig() {
} else if (config_path.has_parent_path()) {
config_.json_file = config_path.string() + def_config_json;
} else {
config_.json_file = exe_path + def_config_json;
config_.json_file = getJsonFile();
}
LogPrintf("Config file path: %s", config_.json_file.c_str());
config_.platform = (amd ? "amd" : (nvidia ? "nvidia" : "unknown"));
config_.os = (p_windows ? "windows" : (p_linux ? "linux" : "unknown"));
if (config_.os == "unknown" || config_.platform == "unknown") {
LogPrintf("%s", "Either Config or Os is unknown, this wont end well");
abort();
}
}
TestContext::TestContext(int argc, char** argv) {
+8 -1
Zobrazit soubor
@@ -68,15 +68,22 @@ class TestContext {
std::string exe_path;
std::string current_test;
std::set<std::string> skip_test;
std::string json_file_;
std::vector<std::string> platform_list_ = {"amd" , "nvidia"};
std::vector<std::string> os_list_ = {"windows", "linux", "all"};
std::vector<std::string> amd_arch_list_ = {};
Config config_;
std::string& getJsonFile();
std::string substringFound( std::vector<std::string> list,
std::string filename);
void detectOS();
void detectPlatform();
void fillConfig();
void setExePath(int, char**);
void parseOptions(int, char**);
bool parseJsonFile();
std::string getMatchingConfigFile(std::string config_dir);
const Config& getConfig() const { return config_; }
TestContext(int argc, char** argv);
+3 -1
Zobrazit soubor
@@ -28,4 +28,6 @@ add_subdirectory(rtc)
add_subdirectory(printf)
add_subdirectory(printfExe)
add_subdirectory(texture)
add_subdirectory(graph)
if(UNIX)
add_subdirectory(graph)
endif()
+3 -5
Zobrazit soubor
@@ -27,8 +27,6 @@ set(TEST_SRC
hipGraphAddMemcpyNode.cc
)
# Create shared lib of all tests
add_library(GraphsTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC})
# Add dependency on build_tests to build it on this custom target
add_dependencies(build_tests GraphsTest)
hip_add_exe_to_target(NAME GraphsTest
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)
+1 -1
Zobrazit soubor
@@ -61,7 +61,7 @@ static __global__ void reduceFinal(double* d_in, double* d_out) {
static void init_input(float* a, size_t size) {
unsigned int seed = time(nullptr);
for (size_t i = 0; i < size; i++) {
a[i] = (rand_r(&seed) & 0xFF) / static_cast<float>(RAND_MAX);
a[i] = (HipTest::RAND_R(&seed) & 0xFF) / static_cast<float>(RAND_MAX);
}
}
+2 -2
Zobrazit soubor
@@ -285,8 +285,8 @@ static bool regressAllocInLoopMthread(int gpu) {
* Thread func to regress alloc and check data consistency
*/
static void threadFunc(int gpu) {
g_thTestPassed = regressAllocInLoopMthread(gpu);
g_thTestPassed = g_thTestPassed & validateMemoryOnGpuMThread(gpu);
g_thTestPassed = regressAllocInLoopMthread(gpu)
&& validateMemoryOnGpuMThread(gpu);
UNSCOPED_INFO("thread execution status on gpu" << gpu << ":" <<
g_thTestPassed.load());