Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some warning from compiler #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Shouren
Copy link

@Shouren Shouren commented Dec 2, 2024

Problem

There are some warnings when building hami-core with gcc 11.4.0 in a container based on nvidia/cuda:12.3.2-devel-ubuntu22.04

root@d7a2fa755ecd:/libvgpu# rm -rf build && bash build.sh
...
/libvgpu/src/allocator/allocator.c: In function 'free_raw_async':
/libvgpu/src/allocator/allocator.c:201:24: warning: implicit declaration of function 'remove_chunk_async'; did you mean 'remove_chunk'? [-Wimplicit-function-declaration]
  201 |     unsigned int tmp = remove_chunk_async(device_overallocated,dptr,hStream);
      |                        ^~~~~~~~~~~~~~~~~~
      |                        remove_chunk
/libvgpu/src/allocator/allocator.c: In function 'allocate_async_raw':
/libvgpu/src/allocator/allocator.c:230:11: warning: implicit declaration of function 'add_chunk_async'; did you mean 'add_chunk_only'? [-Wimplicit-function-declaration]
  230 |     tmp = add_chunk_async(dptr,size,hStream);
      |           ^~~~~~~~~~~~~~~
      |           add_chunk_only
In file included from /libvgpu/src/multiprocess/multiprocess_memory_limit.h:22,
                 from /libvgpu/src/include/memory_limit.h:71,
                 from /libvgpu/src/multiprocess/multiprocess_memory_limit.c:21:
/libvgpu/src/multiprocess/multiprocess_memory_limit.c: In function 'set_gpu_device_sm_utilization':
/libvgpu/src/include/log_utils.h:21:24: warning: format '%lu' expects argument of type 'long unsigned int', but argument 10 has type 'unsigned int' [-Wformat=]
   21 |        fprintf(stderr, "[HAMI-core Info(%d:%ld:%s:%d)]: "msg"\n", getpid(),pthread_self(),basename(__FILE__),__LINE__,##__VA_ARGS__); }
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/libvgpu/src/include/log_utils.h:21:24: note: in definition of macro 'LOG_INFO'
   21 |        fprintf(stderr, "[HAMI-core Info(%d:%ld:%s:%d)]: "msg"\n", getpid(),pthread_self(),basename(__FILE__),__LINE__,##__VA_ARGS__); }
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

......

[ 29%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/memory.c.o
/libvgpu/src/nvml/hook.c: In function 'nvmlDeviceGetMemoryInfo_v2':
/libvgpu/src/nvml/hook.c:371:44: warning: passing argument 2 of '_nvmlDeviceGetMemoryInfo' from incompatible pointer type [-Wincompatible-pointer-types]
  371 |     return _nvmlDeviceGetMemoryInfo(device,memory,2);
      |                                            ^~~~~~
      |                                            |
      |                                            nvmlMemory_v2_t * {aka struct nvmlMemory_v2_st *}
/libvgpu/src/nvml/hook.c:317:73: note: expected 'nvmlMemory_t *' {aka 'struct nvmlMemory_st *'} but argument is of type 'nvmlMemory_v2_t *' {aka 'struct nvmlMemory_v2_st *'}
  317 | nvmlReturn_t _nvmlDeviceGetMemoryInfo(nvmlDevice_t device,nvmlMemory_t* memory,int version) {
      |                                                           ~~~~~~~~~~~~~~^~~~~~

......

[ 91%] Linking C executable test_runtime_host_register
/libvgpu/src/libvgpu.c: In function '__dlsym_hook_section':
/libvgpu/src/libvgpu.c:243:5: warning: 'cuModuleGetTexRef' is deprecated [-Wdeprecated-declarations]
  243 |     DLSYM_HOOK_FUNC(cuModuleGetTexRef);
      |     ^~~~~~~~~~~~~~~
In file included from /libvgpu/src/include/cuda_addition_func.h:4,
                 from /libvgpu/src/libvgpu.c:7:
/usr/local/cuda/include/cuda.h:7256:36: note: declared here
 7256 | __CUDA_DEPRECATED CUresult CUDAAPI cuModuleGetTexRef(CUtexref *pTexRef, CUmodule hmod, const char *name);
      |                                    ^~~~~~~~~~~~~~~~~
/libvgpu/src/libvgpu.c:244:5: warning: 'cuModuleGetSurfRef' is deprecated [-Wdeprecated-declarations]
  244 |     DLSYM_HOOK_FUNC(cuModuleGetSurfRef);
      |     ^~~~~~~~~~~~~~~
In file included from /libvgpu/src/include/cuda_addition_func.h:4,
                 from /libvgpu/src/libvgpu.c:7:
/usr/local/cuda/include/cuda.h:7290:36: note: declared here
 7290 | __CUDA_DEPRECATED CUresult CUDAAPI cuModuleGetSurfRef(CUsurfref *pSurfRef, CUmodule hmod, const char *name);
      |                                    ^~~~~~~~~~~~~~~~~~
[ 93%] Linking C executable ../../shrreg-tool
[ 93%] Built target test_runtime_host_register
[ 95%] Building C object src/CMakeFiles/vgpu.dir/utils.c.o
[ 95%] Built target shrreg-tool
[ 97%] Linking C shared library ../libvgpu.so
[ 97%] Built target vgpu
[100%] Linking CXX executable test_runtime_launch
[100%] Built target test_runtime_launch

Solution

Fix some code and added a cmake option(HOOK_CUDA_DEPRECATED_ENABLE) determine whether a deprecated cuda function should be hooked. For backward compatible, default value of HOOK_CUDA_DEPRECATED_ENABLE is set 1.

This PR applied and HOOK_CUDA_DEPRECATED_ENABLE set to 0

oot@d7a2fa755ecd:/libvgpu# rm -rf build && bash build.sh
CI_COMMIT_BRANCH:unknown
CI_COMMIT_SHA:af47a4c67b4642cfe1d2f6e20c151793caeefcd6
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Git hash is af47a4c
CMake Deprecation Warning at src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "12.3")
-- Configuring done
-- Generating done
-- Build files have been written to: /libvgpu/build
[  6%] Building C object src/multiprocess/CMakeFiles/multiprocess_mod.dir/multiprocess_memory_limit.c.o
[  6%] Building C object src/allocator/CMakeFiles/allocator_mod.dir/allocator.c.o
[  8%] Building C object src/nvml/CMakeFiles/nvml_mod.dir/nvml_entry.c.o
[  8%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/context.c.o
[  8%] Built target allocator_mod
[ 10%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/device.c.o
[ 12%] Building C object test/CMakeFiles/test_alloc.dir/test_alloc.c.o
[ 14%] Building C object src/multiprocess/CMakeFiles/multiprocess_mod.dir/multiprocess_utilization_watcher.c.o
[ 17%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/hook.c.o
[ 19%] Linking C executable test_alloc
[ 19%] Built target test_alloc
[ 19%] Built target multiprocess_mod
[ 21%] Building C object test/CMakeFiles/test_alloc_hold.dir/test_alloc_hold.c.o
[ 23%] Building C object test/CMakeFiles/test_alloc_host.dir/test_alloc_host.c.o
[ 25%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/event.c.o
[ 27%] Building C object src/nvml/CMakeFiles/nvml_mod.dir/hook.c.o
[ 29%] Linking C executable test_alloc_host
[ 31%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/memory.c.o
[ 34%] Linking C executable test_alloc_hold
[ 34%] Built target test_alloc_host
[ 34%] Built target test_alloc_hold
[ 34%] Built target nvml_mod
[ 36%] Building C object test/CMakeFiles/test_alloc_managed.dir/test_alloc_managed.c.o
[ 38%] Building C object test/CMakeFiles/test_alloc_pitch.dir/test_alloc_pitch.c.o
[ 40%] Building C object test/CMakeFiles/test_create_3d_array.dir/test_create_3d_array.c.o
[ 42%] Linking C executable test_alloc_managed
[ 46%] Linking C executable test_alloc_pitch
[ 46%] Linking C executable test_create_3d_array
[ 46%] Built target test_alloc_managed
[ 46%] Built target test_create_3d_array
[ 46%] Built target test_alloc_pitch
[ 48%] Building C object test/CMakeFiles/test_create_array.dir/test_create_array.c.o
[ 53%] Building C object test/CMakeFiles/test_host_register.dir/test_host_register.c.o
[ 53%] Building C object test/CMakeFiles/test_host_alloc.dir/test_host_alloc.c.o
[ 55%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/stream.c.o
[ 57%] Linking C executable test_create_array
[ 59%] Building C object src/cuda/CMakeFiles/cuda_mod.dir/graph.c.o
[ 61%] Linking C executable test_host_alloc
[ 63%] Linking C executable test_host_register
[ 63%] Built target test_create_array
[ 63%] Built target test_host_alloc
[ 63%] Built target test_host_register
[ 65%] Building C object test/CMakeFiles/test_runtime_alloc.dir/test_runtime_alloc.c.o
[ 68%] Building C object test/CMakeFiles/test_runtime_alloc_host.dir/test_runtime_alloc_host.c.o
[ 70%] Building C object test/CMakeFiles/test_runtime_alloc_managed.dir/test_runtime_alloc_managed.c.o
[ 70%] Built target cuda_mod
[ 72%] Linking C executable test_runtime_alloc
[ 74%] Building C object test/CMakeFiles/test_runtime_host_alloc.dir/test_runtime_host_alloc.c.o
[ 76%] Linking C executable test_runtime_alloc_host
[ 78%] Linking C executable test_runtime_alloc_managed
[ 78%] Built target test_runtime_alloc
[ 78%] Built target test_runtime_alloc_host
[ 78%] Built target test_runtime_alloc_managed
[ 80%] Building NVCC (Device) object test/CMakeFiles/test_runtime_launch.dir/test_runtime_launch_generated_test_runtime_launch.cu.o
[ 82%] Building C object test/CMakeFiles/test_runtime_host_register.dir/test_runtime_host_register.c.o
[ 82%] Built target python_test
[ 85%] Building C object src/CMakeFiles/vgpu.dir/libvgpu.c.o
[ 87%] Linking C executable test_runtime_host_alloc
[ 89%] Linking C executable test_runtime_host_register
[ 89%] Built target test_runtime_host_alloc
[ 91%] Building C object src/multiprocess/CMakeFiles/shrreg-tool.dir/shrreg_tool.c.o
[ 91%] Built target test_runtime_host_register
[ 93%] Building C object src/CMakeFiles/vgpu.dir/utils.c.o
[ 95%] Linking C executable ../../shrreg-tool
[ 95%] Built target shrreg-tool
[ 97%] Linking C shared library ../libvgpu.so
[ 97%] Built target vgpu
[100%] Linking CXX executable test_runtime_launch
[100%] Built target test_runtime_launch

@Shouren Shouren force-pushed the fix_some_warning_from_compiler branch from af47a4c to c6acbd6 Compare December 2, 2024 07:41
@Shouren Shouren force-pushed the fix_some_warning_from_compiler branch from c6acbd6 to 39b2cbd Compare December 6, 2024 08:24
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.

1 participant