lamikr / rocm_sdk_builder

Other
113 stars 8 forks source link

Lot of compiler warnings in hipcc hello_world example code #56

Closed lamikr closed 3 weeks ago

lamikr commented 3 weeks ago

When hipcc example is build and exetuded, lot of warnings are generated

$ cd /opt/rocm_sdk_611/docs/examples/hipcc/hello_world/
$ source /opt/rocm_sdk_611/bin/env_rocm.sh  
$ make
/opt/rocm_sdk_611/bin/hipcc -g -fPIE   -c -o hello_world.o hello_world.cpp
hello_world.cpp:48:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   48 |         hipGetDeviceProperties(&devProp, 0);
      |         ^~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
/opt/rocm_sdk_611/include/hip/hip_runtime_api.h:91:32: note: expanded from macro 'hipGetDeviceProperties'
   91 | #define hipGetDeviceProperties hipGetDevicePropertiesR0600
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:62:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   62 |         hipMalloc((void**)&inputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
   63 |                 (strlength + 1) * sizeof(char));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:64:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   64 |         hipMalloc((void**)&outputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
   65 |                 (strlength + 1) * sizeof(char));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:66:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   66 |         hipMemcpy(inputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~
   67 |                 input,
      |                 ~~~~~~
   68 |                 (strlength + 1) * sizeof(char),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                 hipMemcpyHostToDevice);
      |                 ~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:77:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   77 |         hipMemcpy(output,
      |         ^~~~~~~~~ ~~~~~~~
   78 |                 outputBuffer,
      |                 ~~~~~~~~~~~~~
   79 |                 (strlength + 1) * sizeof(char),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 |                 hipMemcpyDeviceToHost);
      |                 ~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:81:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   81 |         hipFree(inputBuffer);
      |         ^~~~~~~ ~~~~~~~~~~~
hello_world.cpp:82:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   82 |         hipFree(outputBuffer);
      |         ^~~~~~~ ~~~~~~~~~~~~
7 warnings generated when compiling for gfx1035.
hello_world.cpp:48:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   48 |         hipGetDeviceProperties(&devProp, 0);
      |         ^~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
/opt/rocm_sdk_611/include/hip/hip_runtime_api.h:91:32: note: expanded from macro 'hipGetDeviceProperties'
   91 | #define hipGetDeviceProperties hipGetDevicePropertiesR0600
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:62:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   62 |         hipMalloc((void**)&inputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
   63 |                 (strlength + 1) * sizeof(char));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:64:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   64 |         hipMalloc((void**)&outputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
   65 |                 (strlength + 1) * sizeof(char));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:66:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   66 |         hipMemcpy(inputBuffer,
      |         ^~~~~~~~~ ~~~~~~~~~~~~
   67 |                 input,
      |                 ~~~~~~
   68 |                 (strlength + 1) * sizeof(char),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                 hipMemcpyHostToDevice);
      |                 ~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:77:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   77 |         hipMemcpy(output,
      |         ^~~~~~~~~ ~~~~~~~
   78 |                 outputBuffer,
      |                 ~~~~~~~~~~~~~
   79 |                 (strlength + 1) * sizeof(char),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 |                 hipMemcpyDeviceToHost);
      |                 ~~~~~~~~~~~~~~~~~~~~~
hello_world.cpp:81:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   81 |         hipFree(inputBuffer);
      |         ^~~~~~~ ~~~~~~~~~~~
hello_world.cpp:82:2: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
   82 |         hipFree(outputBuffer);
      |         ^~~~~~~ ~~~~~~~~~~~~
7 warnings generated when compiling for host.

It should only output the execution command and output from app itself:

/opt/rocm_sdk_611/bin/hipcc hello_world.o -fPIE -o hello_world
./hello_world
 System minor: 3
 System major: 10
 Agent name: AMD Radeon Graphics
Input string: GdkknVnqkc
Output string: HelloWorld
Test ok!