Skip to content

Conversation

@mfbalin
Copy link
Contributor

@mfbalin mfbalin commented Sep 22, 2020

The variable bufferRegion is already declared as const so there is no need for const inside reinterpret_cast.

@mfbalin mfbalin requested a review from a team as a code owner September 22, 2020 10:54
@mfbalin mfbalin requested a review from romanovvlad September 22, 2020 10:54
@romanovvlad
Copy link
Contributor

The variable bufferRegion is already declared as const so there is no need for const inside reinterpret_cast.

Could you please elaborate more on why it is a problem?
Tried to replicate the same situation on godbolt and see no warnings. https://godbolt.org/z/fKv6z5

@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

I am getting the following error during compilation and it gets fixed when I remove the const there.

args:Namespace(base_branch=None, branch=None, build_number=None, build_parallelism='6', builder_dir=None, obj_dir=None, pr_number=None, src_dir=None)
[Cmake Command]: cmake --build /home/mfbalin/sycl_workspace/llvm/build -- deploy-sycl-toolchain deploy-opencl-aot -j 6
[10/1795] Performing update step for 'ocl-headers'
-- ocl-headers update command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-headers-prefix/src/ocl-headers-stamp/ocl-headers-update-*.log
[13/1795] Performing build step for 'ocl-headers'
-- ocl-headers build command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-headers-prefix/src/ocl-headers-stamp/ocl-headers-build-*.log
[16/1795] Performing update step for 'opencl-headers'
HEAD is up to date.
[17/1795] Performing update step for 'level-zero-loader'
-- level-zero-loader update command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/plugins/level_zero/level-zero-loader-prefix/src/level-zero-loader-stamp/level-zero-loader-update-*.log
[18/1795] Performing configure step for 'level-zero-loader'
-- level-zero-loader configure command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/plugins/level_zero/level-zero-loader-prefix/src/level-zero-loader-stamp/level-zero-loader-configure-*.log
[24/1795] Performing update step for 'ocl-icd'
-- ocl-icd update command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-icd-prefix/src/ocl-icd-stamp/ocl-icd-update-*.log
[27/1795] Performing configure step for 'ocl-icd'
-- ocl-icd configure command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-icd-prefix/src/ocl-icd-stamp/ocl-icd-configure-*.log
[28/1795] Performing update step for 'opencl-icd'
HEAD is up to date.
[29/1795] Performing configure step for 'opencl-icd'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mfbalin/sycl_workspace/llvm/build/tools/opencl-aot/icd_build
[30/1795] Performing build step for 'ocl-icd'
-- ocl-icd build command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-icd-prefix/src/ocl-icd-stamp/ocl-icd-build-*.log
[31/1795] Performing install step for 'ocl-icd'
-- ocl-icd install command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/ocl-icd-prefix/src/ocl-icd-stamp/ocl-icd-install-*.log
[34/1795] Performing build step for 'opencl-icd'
[1/4] Building C object CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o
[2/4] Linking C shared library libOpenCL.so.1.2
[3/4] Creating library symlink libOpenCL.so.1 libOpenCL.so
[4/4] Linking C executable test/loader_test/icd_loader_test
[79/970] Performing build step for 'level-zero-loader'
-- level-zero-loader build command succeeded.  See also /home/mfbalin/sycl_workspace/llvm/build/tools/sycl/plugins/level_zero/level-zero-loader-prefix/src/level-zero-loader-stamp/level-zero-loader-build-*.log
[86/970] Building CXX object tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o
FAILED: tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o 
/usr/bin/c++  -DCL_TARGET_OPENCL_VERSION=220 -D_DEBUG -D_GLIBCXX_ASSERTIONS=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dpi_cuda_EXPORTS -Itools/sycl/plugins/cuda -I/home/mfbalin/sycl_workspace/llvm/sycl/plugins/cuda -Iinclude -I/home/mfbalin/sycl_workspace/llvm/llvm/include -I/home/mfbalin/sycl_workspace/llvm/sycl/include -Itools/sycl/OpenCL/inc -isystem /usr/local/cuda/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra -Wno-deprecated-declarations -Werror -O3  -fPIC   -UNDEBUG -std=c++14 -MD -MT tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o -MF tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o.d -o tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o -c /home/mfbalin/sycl_workspace/llvm/sycl/plugins/cuda/pi_cuda.cpp
/home/mfbalin/sycl_workspace/llvm/sycl/plugins/cuda/pi_cuda.cpp: In function ‘pi_result cuda_piMemBufferPartition(pi_mem, pi_mem_flags, pi_buffer_create_type, void*, _pi_mem**)’:
/home/mfbalin/sycl_workspace/llvm/sycl/plugins/cuda/pi_cuda.cpp:1785:8: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
 1785 |       *reinterpret_cast<const pi_buffer_region>(buffer_create_info);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
[91/970] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/mfbalin/sycl_workspace/llvm/buildbot/compile.py", line 67, in <module>
    ret = main()
  File "/home/mfbalin/sycl_workspace/llvm/buildbot/compile.py", line 63, in main
    return do_compile(args)
  File "/home/mfbalin/sycl_workspace/llvm/buildbot/compile.py", line 40, in do_compile
    subprocess.check_call(cmake_cmd, cwd=abs_obj_dir)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '/home/mfbalin/sycl_workspace/llvm/build', '--', 'deploy-sycl-toolchain', 'deploy-opencl-aot', '-j', '6']' returned non-zero exit status 1.```

@mfbalin mfbalin changed the title Fixes warning with GCC 10.1 Fixes warning with GCC 10.2 Sep 22, 2020
@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

I corrected my compiler version in the title

@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

The variable bufferRegion is already declared as const so there is no need for const inside reinterpret_cast.

Could you please elaborate more on why it is a problem?
Tried to replicate the same situation on godbolt and see no warnings. https://godbolt.org/z/fKv6z5

see this https://godbolt.org/z/P3b5K5, actually this might fail to compile because of something else. I am not sure why such a warning I am getting is fixed by this simple change.

@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

For more info, I am on a Ubuntu 20.04 system with g++ (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0. Maybe only my compiler has this problem.

@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

Actually, this reproduces the issue, I copied all compiler flags to compiler explorer to reproduce it.

https://godbolt.org/z/Yhq3P7

@mfbalin
Copy link
Contributor Author

mfbalin commented Sep 22, 2020

This has the least number of compiler flags that still fails to compile

https://godbolt.org/z/xs1Txv

@romanovvlad
Copy link
Contributor

This has the least number of compiler flags that still fails to compile

https://godbolt.org/z/xs1Txv

Thank you, I also found some explanation here https://stackoverflow.com/questions/62733524/why-does-gcc-handle-a-const-reinterpret-cast-different-when-type-alias-is-used .

@bader bader merged commit d76a6a0 into intel:sycl Sep 22, 2020
kbenzie pushed a commit to kbenzie/intel-llvm that referenced this pull request Feb 17, 2025
[L0 v2] implement urKernelSuggestMaxCooperativeGroupCountExp
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
[L0 v2] implement urKernelSuggestMaxCooperativeGroupCountExp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants