Skip to content

Commit

Permalink
[BUG] fix windows kernel dispatch of _lzcnt bug (#53728)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 authored May 15, 2023
1 parent 3e1fffe commit 972daa4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
5 changes: 4 additions & 1 deletion paddle/phi/api/lib/kernel_dispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ std::size_t CountLeadingZeros(uint32_t val) {
#if defined(__clang__) || defined(__GNUC__)
return __builtin_clz(val);
#elif defined(_MSC_VER)
return __lzcnt(val);
// windows don't have built-in clz/ctz function
DWORD Index;
_BitScanReverse(&Index, val);
return (uint32_t)Index ^ 31;
#else
if (val == 0) {
return 32;
Expand Down
2 changes: 0 additions & 2 deletions paddle/phi/kernels/gpu/randperm_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ namespace cub = hipcub;
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/randint_kernel.h"

DECLARE_bool(use_curand);

namespace phi {

template <typename keyT, typename dataT>
Expand Down
20 changes: 9 additions & 11 deletions paddle/scripts/paddle_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if "%WITH_SCCACHE%"=="ON" (
:install_sccache
echo There is not sccache in this PC, will install sccache.
echo Download package from https://paddle-ci.gz.bcebos.com/window_requirement/sccache.exe
%PYTHON_ROOT%\python.exe -c "import wget;wget.download('https://paddle-ci.gz.bcebos.com/window_requirement/sccache.exe')"
python -c "import wget;wget.download('https://paddle-ci.gz.bcebos.com/window_requirement/sccache.exe')"
xcopy sccache.exe %SCCACHE_ROOT%\ /Y
del sccache.exe
goto:eof
Expand Down Expand Up @@ -429,7 +429,7 @@ if not exist %THIRD_PARTY_PATH% (
if not exist %THIRD_PARTY_HOME% mkdir "%THIRD_PARTY_HOME%"
cd /d %THIRD_PARTY_HOME%
echo Getting third party: downloading ...
%PYTHON_ROOT%\python.exe -c "import wget;wget.download('https://paddle-windows.bj.bcebos.com/third_party/%sub_dir%/%md5%.tar.gz')" 2>nul
python -c "import wget;wget.download('https://paddle-windows.bj.bcebos.com/third_party/%sub_dir%/%md5%.tar.gz')" 2>nul
if !ERRORLEVEL! EQU 0 (
echo Getting third party: extracting ...
tar -xf %md5%.tar.gz
Expand Down Expand Up @@ -572,25 +572,23 @@ if %ERRORLEVEL% NEQ 0 (
)

if "%UPLOAD_TP_FILE%"=="ON" (
set BCE_FILE=%cache_dir%\bce-python-sdk-0.8.33\BosClient.py
set BCE_FILE=%cache_dir%\bce-python-sdk-new\BosClient.py
echo Uploading third_party: checking bce ...
if not exist %cache_dir%\bce-python-sdk-0.8.33 (
if not exist %cache_dir%\bce-python-sdk-new (
echo There is no bce in this PC, will install bce.
cd /d %cache_dir%
echo Download package from https://paddle-windows.bj.bcebos.com/bce-python-sdk-0.8.33.tar.gz
%PYTHON_ROOT%\python.exe -c "import wget;wget.download('https://paddle-windows.bj.bcebos.com/bce-python-sdk-0.8.33.tar.gz')"
%PYTHON_ROOT%\python.exe -c "import shutil;shutil.unpack_archive('bce-python-sdk-0.8.33.tar.gz', extract_dir='./',format='gztar')"
cd /d %cache_dir%\bce-python-sdk-0.8.33
%PYTHON_ROOT%\python.exe setup.py install 1>nul
del %cache_dir%\bce-python-sdk-0.8.33.tar.gz
echo Download package from https://xly-devops.bj.bcebos.com/home/bos_new.tar.gz
python -c "import wget;wget.download('https://xly-devops.bj.bcebos.com/home/bos_new.tar.gz')"
python -c "import shutil;shutil.unpack_archive('bos_new.tar.gz', extract_dir='./bce-python-sdk-new',format='gztar')"
python -m pip install bce-python-sdk
)
if !errorlevel! EQU 0 (
cd /d %THIRD_PARTY_HOME%
echo Uploading third_party: compressing ...
tar -zcf %md5%.tar.gz %md5%
if !errorlevel! EQU 0 (
echo Uploading third_party: uploading ...
%PYTHON_ROOT%\python.exe !BCE_FILE! %md5%.tar.gz paddle-windows/third_party/%sub_dir% 1>nul
python !BCE_FILE! %md5%.tar.gz paddle-windows/third_party/%sub_dir% 1>nul
if !errorlevel! EQU 0 (
echo Upload third party %md5% to bos paddle-windows/third_party/%sub_dir% successfully.
) else (
Expand Down

0 comments on commit 972daa4

Please sign in to comment.