owl-project / owl

http://owl-project.github.io
Apache License 2.0
239 stars 54 forks source link

Disable console output for info messages #118

Closed LivelyLiz closed 2 years ago

LivelyLiz commented 2 years ago

Is there a way to disable the console output? I tried some things but they didn't work as I hoped. I describe my approach below (TL;DR I tried setting CMAKE_BUILD_TYPE=Release and NDEBUG but still have logging output)

What I did: I made a project with Owl as dependency via CPM. Currently I am toying around a bit to get my project find Cuda, Optix and Owl, so I used a modified sample s01 as project base to load a model (consisting of a lot of meshes), render an image then close the program. However, when the program closes it spams the console with a warning (?)

owl: context is dying; number of API handles (other than context itself) that have not yet been released (incl this context): 265

and a list consisting of all 265 things that probably should have been released and then a message

\<project path>/build/_deps/owl-src/owl/APIContext.cpp::58: void owl::APIContext::releaseAll() deleting object:...

for each of those 265 things again.

In the source code (context.h), I found that the logging happens in the context and should be disabled when NDEBUGis defined, which is usually the case when using cmake with the -DCMAKE_BUILD_TYPE=Release flag. But neither using this flag, nor setting NDEBUGexplicitly disables the logging for my project. CPM only downloads the source, I add owl in the way described in the README, so CPM shouldn't be the problem here.

I use Ubuntu 20.04, g++ 9.3.0 and the latest commit from the master branch of owl. For reference, this is how I add owl to my project

CPMAddPackage(
    NAME Owl
    GIT_REPOSITORY https://github.com/owl-project/owl.git
    GIT_TAG ca8f7b7e72db600fa7f993cf6e4f471e5895983e
    VERSION 1.0.6
    OPTIONS
        "OptiX_INCLUDE ${OptiX_INCLUDE}"
                "OWL_BUILD_SAMPLES OFF"

        DOWNLOAD_ONLY YES
    )
  if(Owl_ADDED)
    set(OWL_BUILD_SAMPLES OFF)
    set(OptiX_INCLUDE ${OptiX_INCLUDE})
    add_subdirectory(${Owl_SOURCE_DIR} build EXCLUDE_FROM_ALL)
    add_library(Owl INTERFACE)
    #target_include_directories(Owl INTERFACE ${Owl_SOURCE_DIR}/owl/include)
    message(${OWL_INCLUDES})
    target_include_directories(Owl INTERFACE ${OWL_INCLUDES})
    target_link_libraries(Owl INTERFACE ${OWL_LIBRARIES})
    target_compile_definitions(Owl INTERFACE ${OWL_CXX_FLAGS})
  endif()

and I call cmake with cmake -DOptiX_INSTALL_DIR=$HOME/Programs/NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64 -DCMAKE_BUILD_TYPE=Release ..

szellmann commented 2 years ago

FWIW, I recently had a similar issue where owl just wouldn't recognize the build type being set at all. At that time I was in a hurry though and couldn't really investigate what was going on.

I wonder if this is related to the language no longer being C CXX in cmake, but CUDA. I believe that the behavior changed around the time when we switched the language settings in cmake, but haven't gotten around to investigate any further. (I was able to work my way around by setting host compiler flags through CUDA_NVCC_FLAGS then.)

You could maybe check for the compiler flags being set using make VERBOSE=1 when the APIContext.cpp is built, if you wanted to do some more digging. In Release mode I'd also expect flags like -O3 ending up on the command line.

LivelyLiz commented 2 years ago

I don't know what I did differently this time or if I didn't save my changes to the CMakeLists.txt or something but most of the info output is gone now with setting Cmake to Release mode (sorry about that)... The only thing that remains is the output informing about deleting objects. Looking into APIContext.cpp, line 63 and 64, this output is not affected by any flag, it's just plain std::cout instead of using the LOG macro which checks if logging is active. Don't know if this is intended or not but it seems a bit weird. If it is intended, you can consider the issue closed.

PS. The flag gets set

[ 12%] Building CXX object deps/build/owl/CMakeFiles/owl_static.dir/APIContext.cpp.o
cd <project path>/build/deps/build/owl && /usr/bin/c++  
-I/usr/local/cuda-11.4/include -Ihome/Programs/NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/include 
-I<project path>/build/_deps/owl-src/owl/include 
-I<project path>/build/_deps/owl-src 
-I<project path>/build/_deps/owl-src/owl  
--std=c++11 -O3 -DNDEBUG -fPIC   -std=c++11 -o CMakeFiles/owl_static.dir/APIContext.cpp.o 
-c <project path>/build/_deps/owl-src/owl/APIContext.cpp
ingowald commented 2 years ago

The latter is clearly a bug (well, more 'lazyness', i guess); in release mode there shouldn't be any outputs on the console. If anybody can reproduce a case where dbg outputs get unintendedly turned on in release mode please share - that would be very important to track down.

ingowald commented 2 years ago

Just fixing this in release-1.1 branch; not that the push will automatically close this issue once it happens - please feel free to reopen if any more of these issues appear... i'd certainly like to get them all.