diff --git a/CMakeLists.txt b/CMakeLists.txt index 3429e3ee..5506c440 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,60 @@ option(MGE_WITH_MKLDNN "Enable Intel MKL_DNN support," ON) option(MGE_WITH_ROCM "Enable ROCM support" OFF) option(MGE_WITH_LARGE_ARCHIVE "Enable big archive link support" OFF) option(MGE_BUILD_WITH_ASAN "Enable build with ASAN, need compiler support" OFF) +if(MSVC OR WIN32) + option(MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP "Enable deploy inference on Windows xp" OFF) + # special MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2 for Windows XP sp2(32bit) + # internal behavior: + # 1: will force define MGB_HAVE_THREAD=0, which means only support single thread + # 2: some Feature will be disable, eg: MGB_ENABLE_JSON and var sanity check, do + # not too many care this!!, if you want to use this Feature to 'DEBUG', you can + # run same model at NON-XP-SP2 env, eg Win7 or XP-SP3(build without MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2) + # 3: we only support MegEngine(load_and_run) and MegEngineLite API work on XP SP2 + # some debug utils, eg, megbrain_test/megdnn_test not support run, most caused by gtest src code + # sdk caller: + # 1: as we remove mutex, when you use MSVC self API eg CreateThread to start several MegEngine instances + # in the same progress, please call MegEngine API(init/run) as serial as possible, also please + # do not use std::thread std::mutex/std::this_thread_id at SDK caller side!!! + # check dll/exe can deploy on Windows XP sp2 or not: + # please checkout scripts/misc/check_windows_xp_sp2_deploy.py + option(MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2 "Enable deploy inference on Windows xp sp2" OFF) + + # PE file linked by LLVM lld can not run at Windows XP env, so we force use link.exe + # which always locate in Microsoft Visual Studio/*/*/VC/Tools/MSVC/*/bin/*/*/link.exe + if(${MGE_ARCH} STREQUAL "i386") + set(CMAKE_LINKER "link.exe") + message(STATUS "Force use MSVS link when build for i386") + endif() + if(MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP OR MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2) + if(NOT ${MGE_ARCH} STREQUAL "i386") + message(FATAL_ERROR "only support 32bit when build for Windows xp") + endif() + + if(NOT MGE_INFERENCE_ONLY) + message(FATAL_ERROR "only support inference when build for Windows xp") + endif() + + if(MGE_WITH_CUDA) + message(FATAL_ERROR "do not support CUDA when build for Windows xp") + endif() + + # Windows XP sp3 have thread issue, Workround for it + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=0x0501 /Zc:threadSafeInit-") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_WIN32_WINNT=0x0501 /Zc:threadSafeInit-") + # for Windows XP type + add_link_options("/SUBSYSTEM:CONSOLE,5.01") + # some old lib(for example mkl for xp) use legacy stdio, so we force link legacy_stdio_definitions + add_link_options("/DEFAULTLIB:legacy_stdio_definitions.lib") + + if(MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__DEPLOY_ON_XP_SP2__=1") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__DEPLOY_ON_XP_SP2__=1") + endif() + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=0x0601") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_WIN32_WINNT=0x0601") + endif() +endif() if(MSVC OR WIN32) message(STATUS "windows force cudnn static link") @@ -263,7 +317,7 @@ if(MSVC OR WIN32) set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=zero-as-null-pointer-constant -Wno-error=implicit-int-conversion") set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=float-conversion -Wno-error=shadow-field -Wno-error=covered-switch-default") set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=deprecated -Wno-error=documentation -Wno-error=unreachable-code-break") - set(WIN_FLAGS "${WIN_FLAGS} /DWIN32 -Wno-macro-redefined /D_WIN32_WINNT=0x0601 /wd4819") + set(WIN_FLAGS "${WIN_FLAGS} /DWIN32 -Wno-macro-redefined /wd4819") set(WIN_FLAGS "${WIN_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /DNOGDI /D_USE_MATH_DEFINES /bigobj") set(WIN_FLAGS "${WIN_FLAGS} /Zm500 /EHs /wd4351 /wd4291 /wd4250 /wd4996 /wd4819 -Wno-inconsistent-dllimport") @@ -675,7 +729,7 @@ if(MGE_WITH_CUDA) endif() ###########please add_subdirectory from here############### -if((${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386" OR ${MGE_ARCH} STREQUAL "armv7" OR ${MGE_ARCH} STREQUAL "aarch64") AND NOT APPLE) +if((${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386" OR ${MGE_ARCH} STREQUAL "armv7" OR ${MGE_ARCH} STREQUAL "aarch64") AND NOT APPLE AND NOT MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2) option(MGE_ENABLE_CPUINFO "Build cpuinfo library for check runtime." ON) if(MGE_ENABLE_CPUINFO) message(STATUS "Enable cpuinfo runtime check and little kernel optimize.") @@ -821,6 +875,14 @@ if(CMAKE_THREAD_LIBS_INIT OR CMAKE_USE_WIN32_THREADS_INIT OR ANDROID) set(MGB_HAVE_THREAD 1) endif() +if(MSVC OR WIN32) + if(MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2) + message(STATUS "disable MGB_HAVE_THREAD/MGB_ENABLE_JSON when DEPLOY ON XP SP2") + set(MGB_HAVE_THREAD 0) + set(MGB_ENABLE_JSON 0) + endif() +endif() + if(MGE_WITH_TEST) # use intra-op multi threads set(MEGDNN_ENABLE_MULTI_THREADS 1) @@ -851,6 +913,13 @@ else() set(MGB_ENABLE_DEBUG_UTIL 0) endif() +if(MSVC OR WIN32) + if(${MGE_ARCH} STREQUAL "i386") + set(MGB_ENABLE_DEBUG_UTIL 0) + message(STATUS "disable MGB_ENABLE_DEBUG_UTIL at Windows i386 build") + endif() +endif() + # TensorRT set(MGB_ENABLE_TENSOR_RT ${MGE_WITH_TRT}) diff --git a/cmake/mkl.cmake b/cmake/mkl.cmake index 8a5da79f..8315f583 100644 --- a/cmake/mkl.cmake +++ b/cmake/mkl.cmake @@ -4,6 +4,7 @@ find_path(MKL_ROOT_DIR ${PROJECT_SOURCE_DIR}/third_party/mkl/${MGE_ARCH} ${PROJECT_SOURCE_DIR}/third_party/mkl/${MGE_ARCH}/Library ${PROJECT_SOURCE_DIR}/third_party/mkl/x86_32/Library + ${PROJECT_SOURCE_DIR}/third_party/mkl/x86_32 $ENV{MKLDIR} /opt/intel/mkl/*/ /opt/intel/cmkl/*/ diff --git a/scripts/cmake-build/BUILD_README.md b/scripts/cmake-build/BUILD_README.md index e7eb0178..6e673a9f 100755 --- a/scripts/cmake-build/BUILD_README.md +++ b/scripts/cmake-build/BUILD_README.md @@ -129,6 +129,11 @@ Windows shell env(bash from windows-git), infact if you can use git command on W ``` bash.exe ./third_party/prepare.sh bash.exe ./third_party/install-mkl.sh +if you are use github MegEngine and build for Windows XP, please + 1: donwload mkl for xp from: http://registrationcenter-download.intel.com/akdlm/irc_nas/4617/w_mkl_11.1.4.237.exe + 2: install exe, then from install dir: + 2a: cp include file to third_party/mkl/x86_32/include/ + 2b: cp lib file to third_party/mkl/x86_32/lib/ ``` # How to build @@ -137,6 +142,10 @@ bash.exe ./third_party/install-mkl.sh * command: ``` 1: host build just use scripts:scripts/cmake-build/host_build.sh + 1a: build for Windows for XP (sp3): (dbg) EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP=ON" ./scripts/cmake-build/host_build.sh -m -d + (opt) EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP=ON" ./scripts/cmake-build/host_build.sh -m + 2a: build for Windows for XP (sp2): (dbg) EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2=ON" ./scripts/cmake-build/host_build.sh -m -d + (opt) EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2=ON" ./scripts/cmake-build/host_build.sh -m 2: cross build to ARM-Android: scripts/cmake-build/cross_build_android_arm_inference.sh 3: cross build to ARM-Linux: scripts/cmake-build/cross_build_linux_arm_inference.sh 4: cross build to IOS: scripts/cmake-build/cross_build_ios_arm_inference.sh diff --git a/scripts/misc/check_windows_xp_sp2_deploy.py b/scripts/misc/check_windows_xp_sp2_deploy.py new file mode 100755 index 00000000..ac74efd1 --- /dev/null +++ b/scripts/misc/check_windows_xp_sp2_deploy.py @@ -0,0 +1,1093 @@ +#!/usr/bin/env python3 + +import argparse +import os +import platform +import subprocess + +""" +refer to https://docs.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-160 +xp sp2(x86) do not support vc runtime fully, casused by KERNEL32.dll do not implement some base apis +for c++ std function, for example, std::mutex/std::thread, we do not want create a real xp sp2 env or +create a wine xp sp2 env to test load_and_run, as a workround, we test target pe file import functions +are in KERNEL32.dll export function lists or not! +""" + +# cmd.exe /c "dumpbin /exports KERNEL32.dll" +# KERNEL32.dll from Windows xp sp2 2002 C:\WINDOWS\system32 +# please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed +KERNEL32_XP_SP2_EXPORT_SYMBOLS = [ + "ActivateActCtx", + "AddAtomA", + "AddAtomW", + "AddConsoleAliasA", + "AddConsoleAliasW", + "AddLocalAlternateComputerNameA", + "AddLocalAlternateComputerNameW", + "AddRefActCtx", + "AddVectoredExceptionHandler", + "AllocConsole", + "AllocateUserPhysicalPages", + "AreFileApisANSI", + "AssignProcessToJobObject", + "AttachConsole", + "BackupRead", + "BackupSeek", + "BackupWrite", + "BaseCheckAppcompatCache", + "BaseCleanupAppcompatCache", + "BaseCleanupAppcompatCacheSupport", + "BaseDumpAppcompatCache", + "BaseFlushAppcompatCache", + "BaseInitAppcompatCache", + "BaseInitAppcompatCacheSupport", + "BaseProcessInitPostImport", + "BaseQueryModuleData", + "BaseUpdateAppcompatCache", + "BasepCheckWinSaferRestrictions", + "Beep", + "BeginUpdateResourceA", + "BeginUpdateResourceW", + "BindIoCompletionCallback", + "BuildCommDCBA", + "BuildCommDCBAndTimeoutsA", + "BuildCommDCBAndTimeoutsW", + "BuildCommDCBW", + "CallNamedPipeA", + "CallNamedPipeW", + "CancelDeviceWakeupRequest", + "CancelIo", + "CancelTimerQueueTimer", + "CancelWaitableTimer", + "ChangeTimerQueueTimer", + "CheckNameLegalDOS8Dot3A", + "CheckNameLegalDOS8Dot3W", + "CheckRemoteDebuggerPresent", + "ClearCommBreak", + "ClearCommError", + "CloseConsoleHandle", + "CloseHandle", + "CloseProfileUserMapping", + "CmdBatNotification", + "CommConfigDialogA", + "CommConfigDialogW", + "CompareFileTime", + "CompareStringA", + "CompareStringW", + "ConnectNamedPipe", + "ConsoleMenuControl", + "ContinueDebugEvent", + "ConvertDefaultLocale", + "ConvertFiberToThread", + "ConvertThreadToFiber", + "CopyFileA", + "CopyFileExA", + "CopyFileExW", + "CopyFileW", + "CopyLZFile", + "CreateActCtxA", + "CreateActCtxW", + "CreateConsoleScreenBuffer", + "CreateDirectoryA", + "CreateDirectoryExA", + "CreateDirectoryExW", + "CreateDirectoryW", + "CreateEventA", + "CreateEventW", + "CreateFiber", + "CreateFiberEx", + "CreateFileA", + "CreateFileMappingA", + "CreateFileMappingW", + "CreateFileW", + "CreateHardLinkA", + "CreateHardLinkW", + "CreateIoCompletionPort", + "CreateJobObjectA", + "CreateJobObjectW", + "CreateJobSet", + "CreateMailslotA", + "CreateMailslotW", + "CreateMemoryResourceNotification", + "CreateMutexA", + "CreateMutexW", + "CreateNamedPipeA", + "CreateNamedPipeW", + "CreateNlsSecurityDescriptor", + "CreatePipe", + "CreateProcessA", + "CreateProcessInternalA", + "CreateProcessInternalW", + "CreateProcessInternalWSecure", + "CreateProcessW", + "CreateRemoteThread", + "CreateSemaphoreA", + "CreateSemaphoreW", + "CreateSocketHandle", + "CreateTapePartition", + "CreateThread", + "CreateTimerQueue", + "CreateTimerQueueTimer", + "CreateToolhelp32Snapshot", + "CreateVirtualBuffer", + "CreateWaitableTimerA", + "CreateWaitableTimerW", + "DeactivateActCtx", + "DebugActiveProcess", + "DebugActiveProcessStop", + "DebugBreak", + "DebugBreakProcess", + "DebugSetProcessKillOnExit", + "DecodePointer", + "DecodeSystemPointer", + "DefineDosDeviceA", + "DefineDosDeviceW", + "DelayLoadFailureHook", + "DeleteAtom", + "DeleteCriticalSection", + "DeleteFiber", + "DeleteFileA", + "DeleteFileW", + "DeleteTimerQueue", + "DeleteTimerQueueEx", + "DeleteTimerQueueTimer", + "DeleteVolumeMountPointA", + "DeleteVolumeMountPointW", + "DeviceIoControl", + "DisableThreadLibraryCalls", + "DisconnectNamedPipe", + "DnsHostnameToComputerNameA", + "DnsHostnameToComputerNameW", + "DosDateTimeToFileTime", + "DosPathToSessionPathA", + "DosPathToSessionPathW", + "DuplicateConsoleHandle", + "DuplicateHandle", + "EncodePointer", + "EncodeSystemPointer", + "EndUpdateResourceA", + "EndUpdateResourceW", + "EnterCriticalSection", + "EnumCalendarInfoA", + "EnumCalendarInfoExA", + "EnumCalendarInfoExW", + "EnumCalendarInfoW", + "EnumDateFormatsA", + "EnumDateFormatsExA", + "EnumDateFormatsExW", + "EnumDateFormatsW", + "EnumLanguageGroupLocalesA", + "EnumLanguageGroupLocalesW", + "EnumResourceLanguagesA", + "EnumResourceLanguagesW", + "EnumResourceNamesA", + "EnumResourceNamesW", + "EnumResourceTypesA", + "EnumResourceTypesW", + "EnumSystemCodePagesA", + "EnumSystemCodePagesW", + "EnumSystemGeoID", + "EnumSystemLanguageGroupsA", + "EnumSystemLanguageGroupsW", + "EnumSystemLocalesA", + "EnumSystemLocalesW", + "EnumTimeFormatsA", + "EnumTimeFormatsW", + "EnumUILanguagesA", + "EnumUILanguagesW", + "EnumerateLocalComputerNamesA", + "EnumerateLocalComputerNamesW", + "EraseTape", + "EscapeCommFunction", + "ExitProcess", + "ExitThread", + "ExitVDM", + "ExpandEnvironmentStringsA", + "ExpandEnvironmentStringsW", + "ExpungeConsoleCommandHistoryA", + "ExpungeConsoleCommandHistoryW", + "ExtendVirtualBuffer", + "FatalAppExitA", + "FatalAppExitW", + "FatalExit", + "FileTimeToDosDateTime", + "FileTimeToLocalFileTime", + "FileTimeToSystemTime", + "FillConsoleOutputAttribute", + "FillConsoleOutputCharacterA", + "FillConsoleOutputCharacterW", + "FindActCtxSectionGuid", + "FindActCtxSectionStringA", + "FindActCtxSectionStringW", + "FindAtomA", + "FindAtomW", + "FindClose", + "FindCloseChangeNotification", + "FindFirstChangeNotificationA", + "FindFirstChangeNotificationW", + "FindFirstFileA", + "FindFirstFileExA", + "FindFirstFileExW", + "FindFirstFileW", + "FindFirstVolumeA", + "FindFirstVolumeMountPointA", + "FindFirstVolumeMountPointW", + "FindFirstVolumeW", + "FindNextChangeNotification", + "FindNextFileA", + "FindNextFileW", + "FindNextVolumeA", + "FindNextVolumeMountPointA", + "FindNextVolumeMountPointW", + "FindNextVolumeW", + "FindResourceA", + "FindResourceExA", + "FindResourceExW", + "FindResourceW", + "FindVolumeClose", + "FindVolumeMountPointClose", + "FlushConsoleInputBuffer", + "FlushFileBuffers", + "FlushInstructionCache", + "FlushViewOfFile", + "FoldStringA", + "FoldStringW", + "FormatMessageA", + "FormatMessageW", + "FreeConsole", + "FreeEnvironmentStringsA", + "FreeEnvironmentStringsW", + "FreeLibrary", + "FreeLibraryAndExitThread", + "FreeResource", + "FreeUserPhysicalPages", + "FreeVirtualBuffer", + "GenerateConsoleCtrlEvent", + "GetACP", + "GetAtomNameA", + "GetAtomNameW", + "GetBinaryType", + "GetBinaryTypeA", + "GetBinaryTypeW", + "GetCPFileNameFromRegistry", + "GetCPInfo", + "GetCPInfoExA", + "GetCPInfoExW", + "GetCalendarInfoA", + "GetCalendarInfoW", + "GetComPlusPackageInstallStatus", + "GetCommConfig", + "GetCommMask", + "GetCommModemStatus", + "GetCommProperties", + "GetCommState", + "GetCommTimeouts", + "GetCommandLineA", + "GetCommandLineW", + "GetCompressedFileSizeA", + "GetCompressedFileSizeW", + "GetComputerNameA", + "GetComputerNameExA", + "GetComputerNameExW", + "GetComputerNameW", + "GetConsoleAliasA", + "GetConsoleAliasExesA", + "GetConsoleAliasExesLengthA", + "GetConsoleAliasExesLengthW", + "GetConsoleAliasExesW", + "GetConsoleAliasW", + "GetConsoleAliasesA", + "GetConsoleAliasesLengthA", + "GetConsoleAliasesLengthW", + "GetConsoleAliasesW", + "GetConsoleCP", + "GetConsoleCharType", + "GetConsoleCommandHistoryA", + "GetConsoleCommandHistoryLengthA", + "GetConsoleCommandHistoryLengthW", + "GetConsoleCommandHistoryW", + "GetConsoleCursorInfo", + "GetConsoleCursorMode", + "GetConsoleDisplayMode", + "GetConsoleFontInfo", + "GetConsoleFontSize", + "GetConsoleHardwareState", + "GetConsoleInputExeNameA", + "GetConsoleInputExeNameW", + "GetConsoleInputWaitHandle", + "GetConsoleKeyboardLayoutNameA", + "GetConsoleKeyboardLayoutNameW", + "GetConsoleMode", + "GetConsoleNlsMode", + "GetConsoleOutputCP", + "GetConsoleProcessList", + "GetConsoleScreenBufferInfo", + "GetConsoleSelectionInfo", + "GetConsoleTitleA", + "GetConsoleTitleW", + "GetConsoleWindow", + "GetCurrencyFormatA", + "GetCurrencyFormatW", + "GetCurrentActCtx", + "GetCurrentConsoleFont", + "GetCurrentDirectoryA", + "GetCurrentDirectoryW", + "GetCurrentProcess", + "GetCurrentProcessId", + "GetCurrentThread", + "GetCurrentThreadId", + "GetDateFormatA", + "GetDateFormatW", + "GetDefaultCommConfigA", + "GetDefaultCommConfigW", + "GetDefaultSortkeySize", + "GetDevicePowerState", + "GetDiskFreeSpaceA", + "GetDiskFreeSpaceExA", + "GetDiskFreeSpaceExW", + "GetDiskFreeSpaceW", + "GetDllDirectoryA", + "GetDllDirectoryW", + "GetDriveTypeA", + "GetDriveTypeW", + "GetEnvironmentStrings", + "GetEnvironmentStringsA", + "GetEnvironmentStringsW", + "GetEnvironmentVariableA", + "GetEnvironmentVariableW", + "GetExitCodeProcess", + "GetExitCodeThread", + "GetExpandedNameA", + "GetExpandedNameW", + "GetFileAttributesA", + "GetFileAttributesExA", + "GetFileAttributesExW", + "GetFileAttributesW", + "GetFileInformationByHandle", + "GetFileSize", + "GetFileSizeEx", + "GetFileTime", + "GetFileType", + "GetFirmwareEnvironmentVariableA", + "GetFirmwareEnvironmentVariableW", + "GetFullPathNameA", + "GetFullPathNameW", + "GetGeoInfoA", + "GetGeoInfoW", + "GetHandleContext", + "GetHandleInformation", + "GetLargestConsoleWindowSize", + "GetLastError", + "GetLinguistLangSize", + "GetLocalTime", + "GetLocaleInfoA", + "GetLocaleInfoW", + "GetLogicalDriveStringsA", + "GetLogicalDriveStringsW", + "GetLogicalDrives", + "GetLongPathNameA", + "GetLongPathNameW", + "GetMailslotInfo", + "GetModuleFileNameA", + "GetModuleFileNameW", + "GetModuleHandleA", + "GetModuleHandleExA", + "GetModuleHandleExW", + "GetModuleHandleW", + "GetNamedPipeHandleStateA", + "GetNamedPipeHandleStateW", + "GetNamedPipeInfo", + "GetNativeSystemInfo", + "GetNextVDMCommand", + "GetNlsSectionName", + "GetNumaAvailableMemory", + "GetNumaAvailableMemoryNode", + "GetNumaHighestNodeNumber", + "GetNumaNodeProcessorMask", + "GetNumaProcessorMap", + "GetNumaProcessorNode", + "GetNumberFormatA", + "GetNumberFormatW", + "GetNumberOfConsoleFonts", + "GetNumberOfConsoleInputEvents", + "GetNumberOfConsoleMouseButtons", + "GetOEMCP", + "GetOverlappedResult", + "GetPriorityClass", + "GetPrivateProfileIntA", + "GetPrivateProfileIntW", + "GetPrivateProfileSectionA", + "GetPrivateProfileSectionNamesA", + "GetPrivateProfileSectionNamesW", + "GetPrivateProfileSectionW", + "GetPrivateProfileStringA", + "GetPrivateProfileStringW", + "GetPrivateProfileStructA", + "GetPrivateProfileStructW", + "GetProcAddress", + "GetProcessAffinityMask", + "GetProcessHandleCount", + "GetProcessHeap", + "GetProcessHeaps", + "GetProcessId", + "GetProcessIoCounters", + "GetProcessPriorityBoost", + "GetProcessShutdownParameters", + "GetProcessTimes", + "GetProcessVersion", + "GetProcessWorkingSetSize", + "GetProfileIntA", + "GetProfileIntW", + "GetProfileSectionA", + "GetProfileSectionW", + "GetProfileStringA", + "GetProfileStringW", + "GetQueuedCompletionStatus", + "GetShortPathNameA", + "GetShortPathNameW", + "GetStartupInfoA", + "GetStartupInfoW", + "GetStdHandle", + "GetStringTypeA", + "GetStringTypeExA", + "GetStringTypeExW", + "GetStringTypeW", + "GetSystemDefaultLCID", + "GetSystemDefaultLangID", + "GetSystemDefaultUILanguage", + "GetSystemDirectoryA", + "GetSystemDirectoryW", + "GetSystemInfo", + "GetSystemPowerStatus", + "GetSystemRegistryQuota", + "GetSystemTime", + "GetSystemTimeAdjustment", + "GetSystemTimeAsFileTime", + "GetSystemTimes", + "GetSystemWindowsDirectoryA", + "GetSystemWindowsDirectoryW", + "GetSystemWow64DirectoryA", + "GetSystemWow64DirectoryW", + "GetTapeParameters", + "GetTapePosition", + "GetTapeStatus", + "GetTempFileNameA", + "GetTempFileNameW", + "GetTempPathA", + "GetTempPathW", + "GetThreadContext", + "GetThreadIOPendingFlag", + "GetThreadLocale", + "GetThreadPriority", + "GetThreadPriorityBoost", + "GetThreadSelectorEntry", + "GetThreadTimes", + "GetTickCount", + "GetTimeFormatA", + "GetTimeFormatW", + "GetTimeZoneInformation", + "GetUserDefaultLCID", + "GetUserDefaultLangID", + "GetUserDefaultUILanguage", + "GetUserGeoID", + "GetVDMCurrentDirectories", + "GetVersion", + "GetVersionExA", + "GetVersionExW", + "GetVolumeInformationA", + "GetVolumeInformationW", + "GetVolumeNameForVolumeMountPointA", + "GetVolumeNameForVolumeMountPointW", + "GetVolumePathNameA", + "GetVolumePathNameW", + "GetVolumePathNamesForVolumeNameA", + "GetVolumePathNamesForVolumeNameW", + "GetWindowsDirectoryA", + "GetWindowsDirectoryW", + "GetWriteWatch", + "GlobalAddAtomA", + "GlobalAddAtomW", + "GlobalAlloc", + "GlobalCompact", + "GlobalDeleteAtom", + "GlobalFindAtomA", + "GlobalFindAtomW", + "GlobalFix", + "GlobalFlags", + "GlobalFree", + "GlobalGetAtomNameA", + "GlobalGetAtomNameW", + "GlobalHandle", + "GlobalLock", + "GlobalMemoryStatus", + "GlobalMemoryStatusEx", + "GlobalReAlloc", + "GlobalSize", + "GlobalUnWire", + "GlobalUnfix", + "GlobalUnlock", + "GlobalWire", + "Heap32First", + "Heap32ListFirst", + "Heap32ListNext", + "Heap32Next", + "HeapAlloc", + "HeapCompact", + "HeapCreate", + "HeapCreateTagsW", + "HeapDestroy", + "HeapExtend", + "HeapFree", + "HeapLock", + "HeapQueryInformation", + "HeapQueryTagW", + "HeapReAlloc", + "HeapSetInformation", + "HeapSize", + "HeapSummary", + "HeapUnlock", + "HeapUsage", + "HeapValidate", + "HeapWalk", + "InitAtomTable", + "InitializeCriticalSection", + "InitializeCriticalSectionAndSpinCount", + "InitializeSListHead", + "InterlockedCompareExchange", + "InterlockedDecrement", + "InterlockedExchange", + "InterlockedExchangeAdd", + "InterlockedFlushSList", + "InterlockedIncrement", + "InterlockedPopEntrySList", + "InterlockedPushEntrySList", + "InvalidateConsoleDIBits", + "IsBadCodePtr", + "IsBadHugeReadPtr", + "IsBadHugeWritePtr", + "IsBadReadPtr", + "IsBadStringPtrA", + "IsBadStringPtrW", + "IsBadWritePtr", + "IsDBCSLeadByte", + "IsDBCSLeadByteEx", + "IsDebuggerPresent", + "IsProcessInJob", + "IsProcessorFeaturePresent", + "IsSystemResumeAutomatic", + "IsValidCodePage", + "IsValidLanguageGroup", + "IsValidLocale", + "IsValidUILanguage", + "IsWow64Process", + "LCMapStringA", + "LCMapStringW", + "LZClose", + "LZCloseFile", + "LZCopy", + "LZCreateFileW", + "LZDone", + "LZInit", + "LZOpenFileA", + "LZOpenFileW", + "LZRead", + "LZSeek", + "LZStart", + "LeaveCriticalSection", + "LoadLibraryA", + "LoadLibraryExA", + "LoadLibraryExW", + "LoadLibraryW", + "LoadModule", + "LoadResource", + "LocalAlloc", + "LocalCompact", + "LocalFileTimeToFileTime", + "LocalFlags", + "LocalFree", + "LocalHandle", + "LocalLock", + "LocalReAlloc", + "LocalShrink", + "LocalSize", + "LocalUnlock", + "LockFile", + "LockFileEx", + "LockResource", + "MapUserPhysicalPages", + "MapUserPhysicalPagesScatter", + "MapViewOfFile", + "MapViewOfFileEx", + "Module32First", + "Module32FirstW", + "Module32Next", + "Module32NextW", + "MoveFileA", + "MoveFileExA", + "MoveFileExW", + "MoveFileW", + "MoveFileWithProgressA", + "MoveFileWithProgressW", + "MulDiv", + "MultiByteToWideChar", + "NlsConvertIntegerToString", + "NlsGetCacheUpdateCount", + "NlsResetProcessLocale", + "NumaVirtualQueryNode", + "OpenConsoleW", + "OpenDataFile", + "OpenEventA", + "OpenEventW", + "OpenFile", + "OpenFileMappingA", + "OpenFileMappingW", + "OpenJobObjectA", + "OpenJobObjectW", + "OpenMutexA", + "OpenMutexW", + "OpenProcess", + "OpenProfileUserMapping", + "OpenSemaphoreA", + "OpenSemaphoreW", + "OpenThread", + "OpenWaitableTimerA", + "OpenWaitableTimerW", + "OutputDebugStringA", + "OutputDebugStringW", + "PeekConsoleInputA", + "PeekConsoleInputW", + "PeekNamedPipe", + "PostQueuedCompletionStatus", + "PrepareTape", + "PrivCopyFileExW", + "PrivMoveFileIdentityW", + "Process32First", + "Process32FirstW", + "Process32Next", + "Process32NextW", + "ProcessIdToSessionId", + "PulseEvent", + "PurgeComm", + "QueryActCtxW", + "QueryDepthSList", + "QueryDosDeviceA", + "QueryDosDeviceW", + "QueryInformationJobObject", + "QueryMemoryResourceNotification", + "QueryPerformanceCounter", + "QueryPerformanceFrequency", + "QueryWin31IniFilesMappedToRegistry", + "QueueUserAPC", + "QueueUserWorkItem", + "RaiseException", + "ReadConsoleA", + "ReadConsoleInputA", + "ReadConsoleInputExA", + "ReadConsoleInputExW", + "ReadConsoleInputW", + "ReadConsoleOutputA", + "ReadConsoleOutputAttribute", + "ReadConsoleOutputCharacterA", + "ReadConsoleOutputCharacterW", + "ReadConsoleOutputW", + "ReadConsoleW", + "ReadDirectoryChangesW", + "ReadFile", + "ReadFileEx", + "ReadFileScatter", + "ReadProcessMemory", + "RegisterConsoleIME", + "RegisterConsoleOS2", + "RegisterConsoleVDM", + "RegisterWaitForInputIdle", + "RegisterWaitForSingleObject", + "RegisterWaitForSingleObjectEx", + "RegisterWowBaseHandlers", + "RegisterWowExec", + "ReleaseActCtx", + "ReleaseMutex", + "ReleaseSemaphore", + "RemoveDirectoryA", + "RemoveDirectoryW", + "RemoveLocalAlternateComputerNameA", + "RemoveLocalAlternateComputerNameW", + "RemoveVectoredExceptionHandler", + "ReplaceFile", + "ReplaceFileA", + "ReplaceFileW", + "RequestDeviceWakeup", + "RequestWakeupLatency", + "ResetEvent", + "ResetWriteWatch", + "RestoreLastError", + "ResumeThread", + "RtlCaptureContext", + "RtlCaptureStackBackTrace", + "RtlFillMemory", + "RtlMoveMemory", + "RtlUnwind", + "RtlZeroMemory", + "ScrollConsoleScreenBufferA", + "ScrollConsoleScreenBufferW", + "SearchPathA", + "SearchPathW", + "SetCPGlobal", + "SetCalendarInfoA", + "SetCalendarInfoW", + "SetClientTimeZoneInformation", + "SetComPlusPackageInstallStatus", + "SetCommBreak", + "SetCommConfig", + "SetCommMask", + "SetCommState", + "SetCommTimeouts", + "SetComputerNameA", + "SetComputerNameExA", + "SetComputerNameExW", + "SetComputerNameW", + "SetConsoleActiveScreenBuffer", + "SetConsoleCP", + "SetConsoleCommandHistoryMode", + "SetConsoleCtrlHandler", + "SetConsoleCursor", + "SetConsoleCursorInfo", + "SetConsoleCursorMode", + "SetConsoleCursorPosition", + "SetConsoleDisplayMode", + "SetConsoleFont", + "SetConsoleHardwareState", + "SetConsoleIcon", + "SetConsoleInputExeNameA", + "SetConsoleInputExeNameW", + "SetConsoleKeyShortcuts", + "SetConsoleLocalEUDC", + "SetConsoleMaximumWindowSize", + "SetConsoleMenuClose", + "SetConsoleMode", + "SetConsoleNlsMode", + "SetConsoleNumberOfCommandsA", + "SetConsoleNumberOfCommandsW", + "SetConsoleOS2OemFormat", + "SetConsoleOutputCP", + "SetConsolePalette", + "SetConsoleScreenBufferSize", + "SetConsoleTextAttribute", + "SetConsoleTitleA", + "SetConsoleTitleW", + "SetConsoleWindowInfo", + "SetCriticalSectionSpinCount", + "SetCurrentDirectoryA", + "SetCurrentDirectoryW", + "SetDefaultCommConfigA", + "SetDefaultCommConfigW", + "SetDllDirectoryA", + "SetDllDirectoryW", + "SetEndOfFile", + "SetEnvironmentVariableA", + "SetEnvironmentVariableW", + "SetErrorMode", + "SetEvent", + "SetFileApisToANSI", + "SetFileApisToOEM", + "SetFileAttributesA", + "SetFileAttributesW", + "SetFilePointer", + "SetFilePointerEx", + "SetFileShortNameA", + "SetFileShortNameW", + "SetFileTime", + "SetFileValidData", + "SetFirmwareEnvironmentVariableA", + "SetFirmwareEnvironmentVariableW", + "SetHandleContext", + "SetHandleCount", + "SetHandleInformation", + "SetInformationJobObject", + "SetLastConsoleEventActive", + "SetLastError", + "SetLocalPrimaryComputerNameA", + "SetLocalPrimaryComputerNameW", + "SetLocalTime", + "SetLocaleInfoA", + "SetLocaleInfoW", + "SetMailslotInfo", + "SetMessageWaitingIndicator", + "SetNamedPipeHandleState", + "SetPriorityClass", + "SetProcessAffinityMask", + "SetProcessPriorityBoost", + "SetProcessShutdownParameters", + "SetProcessWorkingSetSize", + "SetStdHandle", + "SetSystemPowerState", + "SetSystemTime", + "SetSystemTimeAdjustment", + "SetTapeParameters", + "SetTapePosition", + "SetTermsrvAppInstallMode", + "SetThreadAffinityMask", + "SetThreadContext", + "SetThreadExecutionState", + "SetThreadIdealProcessor", + "SetThreadLocale", + "SetThreadPriority", + "SetThreadPriorityBoost", + "SetThreadUILanguage", + "SetTimeZoneInformation", + "SetTimerQueueTimer", + "SetUnhandledExceptionFilter", + "SetUserGeoID", + "SetVDMCurrentDirectories", + "SetVolumeLabelA", + "SetVolumeLabelW", + "SetVolumeMountPointA", + "SetVolumeMountPointW", + "SetWaitableTimer", + "SetupComm", + "ShowConsoleCursor", + "SignalObjectAndWait", + "SizeofResource", + "Sleep", + "SleepEx", + "SuspendThread", + "SwitchToFiber", + "SwitchToThread", + "SystemTimeToFileTime", + "SystemTimeToTzSpecificLocalTime", + "TerminateJobObject", + "TerminateProcess", + "TerminateThread", + "TermsrvAppInstallMode", + "Thread32First", + "Thread32Next", + "TlsAlloc", + "TlsFree", + "TlsGetValue", + "TlsSetValue", + "Toolhelp32ReadProcessMemory", + "TransactNamedPipe", + "TransmitCommChar", + "TrimVirtualBuffer", + "TryEnterCriticalSection", + "TzSpecificLocalTimeToSystemTime", + "UTRegister", + "UTUnRegister", + "UnhandledExceptionFilter", + "UnlockFile", + "UnlockFileEx", + "UnmapViewOfFile", + "UnregisterConsoleIME", + "UnregisterWait", + "UnregisterWaitEx", + "UpdateResourceA", + "UpdateResourceW", + "VDMConsoleOperation", + "VDMOperationStarted", + "ValidateLCType", + "ValidateLocale", + "VerLanguageNameA", + "VerLanguageNameW", + "VerSetConditionMask", + "VerifyConsoleIoHandle", + "VerifyVersionInfoA", + "VerifyVersionInfoW", + "VirtualAlloc", + "VirtualAllocEx", + "VirtualBufferExceptionHandler", + "VirtualFree", + "VirtualFreeEx", + "VirtualLock", + "VirtualProtect", + "VirtualProtectEx", + "VirtualQuery", + "VirtualQueryEx", + "VirtualUnlock", + "WTSGetActiveConsoleSessionId", + "WaitCommEvent", + "WaitForDebugEvent", + "WaitForMultipleObjects", + "WaitForMultipleObjectsEx", + "WaitForSingleObject", + "WaitForSingleObjectEx", + "WaitNamedPipeA", + "WaitNamedPipeW", + "WideCharToMultiByte", + "WinExec", + "WriteConsoleA", + "WriteConsoleInputA", + "WriteConsoleInputVDMA", + "WriteConsoleInputVDMW", + "WriteConsoleInputW", + "WriteConsoleOutputA", + "WriteConsoleOutputAttribute", + "WriteConsoleOutputCharacterA", + "WriteConsoleOutputCharacterW", + "WriteConsoleOutputW", + "WriteConsoleW", + "WriteFile", + "WriteFileEx", + "WriteFileGather", + "WritePrivateProfileSectionA", + "WritePrivateProfileSectionW", + "WritePrivateProfileStringA", + "WritePrivateProfileStringW", + "WritePrivateProfileStructA", + "WritePrivateProfileStructW", + "WriteProcessMemory", + "WriteProfileSectionA", + "WriteProfileSectionW", + "WriteProfileStringA", + "WriteProfileStringW", + "WriteTapemark", + "ZombifyActCtx", + "_hread", + "_hwrite", + "_lclose", + "_lcreat", + "_llseek", + "_lopen", + "_lread", + "_lwrite", + "lstrcat", + "lstrcatA", + "lstrcatW", + "lstrcmp", + "lstrcmpA", + "lstrcmpW", + "lstrcmpi", + "lstrcmpiA", + "lstrcmpiW", + "lstrcpy", + "lstrcpyA", + "lstrcpyW", + "lstrcpyn", + "lstrcpynA", + "lstrcpynW", + "lstrlen", + "lstrlenA", + "lstrlenW", +] +# please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed + + +# please do not add function in STRIP_LINES when your MR failed +STRIP_LINES = [ + "Dumper Version", + "Microsoft Corporation", + "Dump of file", + "File Type", + "Section contains the", + "Import Address Table", + "Import Name Table", + "time date stamp", + "Index of first forwarder reference", + "Summary", + ".data", + ".gfids", + ".rdata", + ".reloc", + ".text", + ".tls", + ".rsrc", + ".00cfg", + ".idata", + "KERNEL32.dll", + "dbghelp.dll", +] +# please do not add function in STRIP_LINES when your MR failed + +# please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed +CONSOLE_LINES = [ + "operating system version", + "subsystem version", +] +CONSOLE_VERSION = [ + "5.01", +] +# please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed + + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument( + "-p", + "--windows_pe_file", + help="pe file check runnable on Windows xp sp2", + dest="pe_file", + type=str, + required=True, + ) + + args = parser.parse_args() + + if not os.path.isfile(args.pe_file): + print("ERROR: can not find file:{}".format(args.pe_file)) + exit(-1) + + cmd = 'cmd.exe /c "dumpbin /imports {}"'.format(args.pe_file) + raw_log = subprocess.check_output(cmd) + raw_log = raw_log.decode("utf-8").split("\r\n") + + import_function = [] + for log in raw_log: + is_in_strip = False + if log != "": + for strip_line in STRIP_LINES: + if log.find(strip_line) >= 0: + is_in_strip = True + break + if not is_in_strip: + import_function.append(log.split()[1]) + + assert len(import_function) > 0, "import function should not be zero" + + # now check import_function is in KERNEL32_XP_SP2_EXPORT_SYMBOLS + # if you MR failed!, please ref 65ac48b95e99f2c510fe5db449cc8182d682e113 + # to refine your MR + + for i in import_function: + msg = ( + "target import function: '{}' can not find in KERNEL32_XP_SP2_EXPORT_SYMBOLS\n" + "please check your MR modify, possible reasons:\n" + "1: use std::thread/std::this_thread in inference code, put this code under #if !__DEPLOY_ON_XP_SP2__\n" + "2: use std::mutex in inference code, replace it to DNN_MUTEX/MGB_MUTEX/LITE_MUTEX\n" + "3: more detail please do git show 65ac48b95e99f2c510fe5db449cc8182d682e113 to refine your MR".format( + i + ) + ) + assert i in KERNEL32_XP_SP2_EXPORT_SYMBOLS, "{}".format(msg) + print("check import fuction: '{}' success".format(i)) + + print("check pe file: {} import function success!!!".format(args.pe_file)) + + cmd = 'cmd.exe /c "dumpbin /HEADERS {}"'.format(args.pe_file) + raw_log = subprocess.check_output(cmd) + raw_log = raw_log.decode("utf-8").split("\r\n") + + console_version = [] + for log in raw_log: + for console_line in CONSOLE_LINES: + if log.find(console_line) >= 0: + console_version.append(log.split()[0]) + + assert len(console_version) > 0, "console version should not be zero" + + # now check console version + + for i in console_version: + msg = ( + "check console version: '{}' failed\n" + "please check your MR modify, possible reasons:\n" + "1: need add /SUBSYSTEM:CONSOLE,5.01 for linker when (cmake)define MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2\n" + ' bazel --copt "-D__DEPLOY_ON_XP_SP2__=1"'.format(i) + ) + assert i in CONSOLE_VERSION, "{}".format(msg) + print("check console version: '{}' success".format(i)) + + print("check pe file: {} console version success!!!".format(args.pe_file)) + + +if __name__ == "__main__": + assert platform.system() == "Windows", "can only run at windows env!!!" + main() diff --git a/src/core/impl/comp_node/cpu/comp_node.cpp b/src/core/impl/comp_node/cpu/comp_node.cpp index 0ac86e7d..52469f53 100644 --- a/src/core/impl/comp_node/cpu/comp_node.cpp +++ b/src/core/impl/comp_node/cpu/comp_node.cpp @@ -834,9 +834,7 @@ struct CpuCompNode::Pool { void operator()(CompNodeRecorderImpl* p) { p->~CompNodeRecorderImpl(); } }; -#if !__DEPLOY_ON_XP_SP2__ - std::recursive_mutex mtx; -#endif + MGB_RECURSIVE_MUTEX mtx; // use global memory pool to ensuare object memory accessible even after // global finalize std::aligned_storage_t callback) { for (size_t i = 0;; ++i) { CompNode cur; { -#if !__DEPLOY_ON_XP_SP2__ MGB_LOCK_GUARD(sm_pool->mtx); -#endif if (i >= sm_pool->nr_used_impl_storage) return; cur = make_comp_node_from_impl( @@ -917,9 +913,7 @@ CpuCompNode::Impl* CpuCompNode::load_cpu(Locator locator, locator.device == Locator::DEVICE_MULTITHREAD_DEFAULT, "failed to load cpu for device:%d stream:%d", locator.device, locator.stream); -#if !__DEPLOY_ON_XP_SP2__ MGB_LOCK_GUARD(sm_pool->mtx); -#endif // encode both device ID and type into a int mgb_assert(locator_logical.device >= -1 || @@ -977,9 +971,7 @@ void CpuCompNode::sync_all() { if (!sm_pool) return; -#if !__DEPLOY_ON_XP_SP2__ MGB_LOCK_GUARD(sm_pool->mtx); -#endif for (auto&& i : sm_pool->locator2impl) i.second->sync(); for (auto&& i : sm_pool->locator2impl_multi_thread) @@ -1061,9 +1053,7 @@ void CpuCompNode::CpuDispatchableBase::EventImpl::do_device_wait_by( auto waiter = [this, version]() { while (m_record_nr_finish.load(std::memory_order_acquire) < version) { -#if !__DEPLOY_ON_XP_SP2__ std::unique_lock lk{m_dev_wait_mtx}; -#endif if (m_record_nr_finish.load(std::memory_order_acquire) >= version) { break; } @@ -1092,12 +1082,10 @@ void CpuCompNode::CpuDispatchableBase::EventImpl::on_finish() { } m_record_nr_finish.fetch_add(1, std::memory_order_release); -#if !__DEPLOY_ON_XP_SP2__ if (m_dev_wait_nr_waiter.load(std::memory_order_acquire)) { MGB_LOCK_GUARD(m_dev_wait_mtx); m_dev_wait_cv.notify_all(); } -#endif } bool CpuCompNode::CpuDispatchableBase::EventImpl::do_finished() { @@ -1116,15 +1104,11 @@ void CpuCompNode::CpuDispatchableBase::EventImpl::host_wait_cv() { m_dev_wait_nr_waiter.fetch_add(1, std::memory_order_release); for (;;) { -#if !__DEPLOY_ON_XP_SP2__ std::unique_lock lock{m_dev_wait_mtx}; -#endif if (finished()) { break; } -#if !__DEPLOY_ON_XP_SP2__ m_dev_wait_cv.wait(lock); -#endif } m_dev_wait_nr_waiter.fetch_sub(1, std::memory_order_release); } diff --git a/src/core/include/megbrain/utils/thread_pool.h b/src/core/include/megbrain/utils/thread_pool.h index 9edffd43..005a8f49 100644 --- a/src/core/include/megbrain/utils/thread_pool.h +++ b/src/core/include/megbrain/utils/thread_pool.h @@ -36,6 +36,7 @@ struct TaskElem { size_t nr_parallelism; }; +#if MGB_HAVE_THREAD /** * \brief Worker and related flag */ @@ -53,7 +54,6 @@ public: bool affinity_flag{false}; }; -#if MGB_HAVE_THREAD /** * \brief ThreadPool execute the task in multi-threads(nr_threads>1) mode , it * will fallback to single-thread mode if nr_thread is 1. diff --git a/src/plugin/impl/var_sanity_check.cpp b/src/plugin/impl/var_sanity_check.cpp index 9bb4b00b..a9692c5c 100644 --- a/src/plugin/impl/var_sanity_check.cpp +++ b/src/plugin/impl/var_sanity_check.cpp @@ -9,6 +9,7 @@ * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +#if !__DEPLOY_ON_XP_SP2__ #include "megbrain/plugin/var_sanity_check.h" #include "megbrain/comp_node_env.h" #include "megbrain/graph/event.h" @@ -363,5 +364,6 @@ void VarSanityCheck::setup_input_checker(bool add_debug_log, env.dispatch_on_comp_node(cn, callback); } } +#endif // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}} diff --git a/src/plugin/include/megbrain/plugin/var_sanity_check.h b/src/plugin/include/megbrain/plugin/var_sanity_check.h index f18b0dde..6e3c4fec 100644 --- a/src/plugin/include/megbrain/plugin/var_sanity_check.h +++ b/src/plugin/include/megbrain/plugin/var_sanity_check.h @@ -11,6 +11,7 @@ #pragma once +#if !__DEPLOY_ON_XP_SP2__ #include "megbrain/exception.h" #include "megbrain/graph.h" #include "megbrain/plugin/base.h" @@ -106,5 +107,6 @@ public: VarNode* var, const ComputingGraph::VarReceiverInfo& recv); }; } // namespace mgb +#endif // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}} diff --git a/third_party/install-mkl.sh b/third_party/install-mkl.sh index 666d0bd3..d936a053 100755 --- a/third_party/install-mkl.sh +++ b/third_party/install-mkl.sh @@ -13,7 +13,6 @@ CONDA_BASE_URL=https://anaconda.org/intel OS=$(uname -s) FILE_PREFIX=null TAR=tar - if [ $OS = "Darwin" ];then FILE_PREFIX=osx elif [ $OS = "Linux" ];then @@ -32,20 +31,24 @@ echo "config FILE_PREFIX to: $FILE_PREFIX" rm -rf mkl -for platform in 32 64 -do - if [ $OS = "Darwin" ]&&[ $platform = 32 ];then - echo "strip 32 bit file for Darwin" - continue - fi - mkdir -p mkl/x86_${platform} - for package in "mkl-include" "mkl-static" +if [[ -z ${ALREADY_INSTALL_MKL} ]] +then + echo "init mkl from software.intel.com" + for platform in 32 64 do - DOWNLOAD_FILE=${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2 - echo "Installing ${DOWNLOAD_FILE} for x86_${platform}..." - URL=${CONDA_BASE_URL}/${package}/${MKL_VERSION}/download/$FILE_PREFIX-${platform}/${DOWNLOAD_FILE} - echo "try download mkl package from: ${URL}" - wget -q --show-progress "${URL}" -O mkl/x86_${platform}/${DOWNLOAD_FILE} - $TAR xvj -C mkl/x86_${platform} -f mkl/x86_${platform}/${DOWNLOAD_FILE} + if [ $OS = "Darwin" ]&&[ $platform = 32 ];then + echo "strip 32 bit file for Darwin" + continue + fi + mkdir -p mkl/x86_${platform} + for package in "mkl-include" "mkl-static" + do + DOWNLOAD_FILE=${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2 + echo "Installing ${DOWNLOAD_FILE} for x86_${platform}..." + URL=${CONDA_BASE_URL}/${package}/${MKL_VERSION}/download/$FILE_PREFIX-${platform}/${DOWNLOAD_FILE} + echo "try download mkl package from: ${URL}" + wget -q --show-progress "${URL}" -O mkl/x86_${platform}/${DOWNLOAD_FILE} + $TAR xvj -C mkl/x86_${platform} -f mkl/x86_${platform}/${DOWNLOAD_FILE} + done done -done +fi