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

Cannot init any type of Executor #959

Closed
duzhen1996 opened this issue Jan 28, 2022 · 5 comments
Closed

Cannot init any type of Executor #959

duzhen1996 opened this issue Jan 28, 2022 · 5 comments

Comments

@duzhen1996
Copy link

duzhen1996 commented Jan 28, 2022

Hello.

I want to try this library in our environment. I have successfully installed it. It almost works, but I can't pass the compiling while I init a Executor:

auto exec = gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true);

I use command as follows to compile it:

/usr/bin/g++ -lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_device -lginkgo_dpcpp -lginkgo_hip main.cc

And error like this appears:

/usr/bin/ld: /tmp/ccCIpD0K.o: in function `main':
sell.cc:(.text+0x1a8): undefined reference to `gko::CudaExecutor::create(int, std::shared_ptr<gko::Executor>, bool, gko::allocation_mode)'
/usr/bin/ld: /tmp/ccCIpD0K.o: in function `gko::MachineTopology::get_instance()':
sell.cc:(.text._ZN3gko15MachineTopology12get_instanceEv[_ZN3gko15MachineTopology12get_instanceEv]+0x3e): undefined reference to `gko::MachineTopology::MachineTopology()'
/usr/bin/ld: /tmp/ccCIpD0K.o: in function `gko::OmpExecutor::OmpExecutor()':
sell.cc:(.text._ZN3gko11OmpExecutorC2Ev[_ZN3gko11OmpExecutorC5Ev]+0x32): undefined reference to `vtable for gko::OmpExecutor'
/usr/bin/ld: sell.cc:(.text._ZN3gko11OmpExecutorC2Ev[_ZN3gko11OmpExecutorC5Ev]+0x50): undefined reference to `gko::OmpExecutor::populate_exec_info(gko::MachineTopology const*)'
collect2: error: ld returned 1 exit status

I try code like this, and it can pass the compiles, so I guest this error only appears in executor init.

using mtx = gko::matrix::Dense<double>;

I use like command to config ginkgo while installing:

cmake  -G "Unix Makefiles" -H. -DGINKGO_DEVEL_TOOLS=OFF  -DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_REFERENCE=ON -DGINKGO_BUILD_OMP=ON -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_HWLOC=ON ..
-- Found OpenMP_C: -fopenmp (Required is at least version "3.0") 
-- Found OpenMP_CXX: -fopenmp (Required is at least version "3.0") 
-- GINKGO_BUILD_TESTS is ON, enabling GINKGO_BUILD_REFERENCE
-- Could NOT find PAPI (missing: PAPI_LIBRARY PAPI_INCLUDE_DIR) 
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) (Required is at least version "1.10.0")
-- Looking for HWLOC - found version 2.1.0
-- Looking for hwloc_topology_init
-- Looking for hwloc_topology_init - found
-- Fetching external GTest
fatal: not a git repository (or any of the parent directories): .git
-- Ginkgo is not in a git repository, so no git hook was installed
-- Fetching external GFlags
-- Fetching external RapidJSON
-- Found OpenMP_C: -fopenmp (Required is at least version "3.0") 
-- Found OpenMP_CXX: -fopenmp (Required is at least version "3.0") 
-- Found OpenMP_C: -fopenmp (Required is at least version "3.0") 
-- Found OpenMP_CXX: -fopenmp (Required is at least version "3.0") 
-- No OpenCV found, disabling heat-equation example

---------------------------------------------------------------------------------------------------------
--
--    Summary of Configuration for Ginkgo (version 1.4.0 with tag master)
--
--    Ginkgo configuration:
--        CMAKE_BUILD_TYPE:                           Release
--        BUILD_SHARED_LIBS:                          ON
--        CMAKE_INSTALL_PREFIX:                       /usr/local
--        PROJECT_SOURCE_DIR:                         /home/duzhen/ginkgo-1.4.0
--        PROJECT_BINARY_DIR:                         /home/duzhen/ginkgo-1.4.0/build
--        CMAKE_CXX_COMPILER:                         GNU 9.3.0 on platform Linux x86_64
--                                                    /usr/bin/c++
--    User configuration:
--      Enabled modules:
--        GINKGO_BUILD_OMP:                           ON
--        GINKGO_BUILD_REFERENCE:                     ON
--        GINKGO_BUILD_CUDA:                          ON
--        GINKGO_BUILD_HIP:                           OFF
--        GINKGO_BUILD_DPCPP:                         OFF
--      Enabled features:
--        GINKGO_MIXED_PRECISION:                     OFF
--      Tests, benchmarks and examples:
--        GINKGO_BUILD_TESTS:                         ON
--        GINKGO_FAST_TESTS:                          OFF
--        GINKGO_BUILD_EXAMPLES:                      ON
--        GINKGO_EXTLIB_EXAMPLE:                      
--        GINKGO_BUILD_BENCHMARKS:                    ON
--        GINKGO_BENCHMARK_ENABLE_TUNING:             OFF
--      Documentation:
--        GINKGO_BUILD_DOC:                           OFF
--        GINKGO_VERBOSE_LEVEL:                       1
--    
---------------------------------------------------------------------------------------------------------
--
--      Developer Tools:
--        GINKGO_DEVEL_TOOLS:                         OFF
--        GINKGO_WITH_CLANG_TIDY:                     OFF
--        GINKGO_WITH_IWYU:                           OFF
--        GINKGO_CHECK_CIRCULAR_DEPS:                 OFF
--        GINKGO_WITH_CCACHE:                         ON
---------------------------------------------------------------------------------------------------------
--
--      Components:
--        GINKGO_BUILD_HWLOC:                         ON
--
--  Detailed information (More compiler flags, module configuration) can be found in detailed.log
--   
--
--  Now, run  cmake --build .  to compile Ginkgo!
--
---------------------------------------------------------------------------------------------------------

-- Configuring done
-- Generating done
-- Build files have been written to: /home/duzhen/ginkgo-1.4.0/build

My g++ version is 9.3.0. And CUDA version is 11.

@yhmtsai
Copy link
Member

yhmtsai commented Jan 28, 2022

Could you try
/usr/bin/g++ main.cc -lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_device -lginkgo_dpcpp -lginkgo_hip
and
/usr/bin/g++ main.cc -lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_hip -lginkgo_dpcpp -lginkgo_device?

both might also need -lhwloc

@upsj
Copy link
Member

upsj commented Jan 28, 2022

The "canonical" way to link against Ginkgo in a Makefile environment is using the output of pkg-config --libs ginkgo, since that models the link dependencies correctly, in your case you are missing -lginkgo_device, in total:
-lginkgo -lginkgo_device -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_hip -lginkgo_dpcpp
HWLOC might be missing in the output, but that is being fixed in #923

I would heavily recommend using CMake though, since it gives the most smooth integration.

@Slaedr
Copy link
Contributor

Slaedr commented Feb 1, 2022

@upsj The OP was already using -lginkgo_device. From Mike's reply, the main difference on my setup was that the main.cc needs to come before all the libraries when building and linking in one step. Maybe this is a noob thing but I was not expecting that to matter.

@upsj
Copy link
Member

upsj commented Mar 4, 2022

@duzhen1996 were you able to make any progress? Please let us know if we can assist any further, otherwise we will close this issue soon.

@duzhen1996
Copy link
Author

@upsj Thanks for your attention! You can close this issue now.

@upsj upsj closed this as completed Mar 7, 2022
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

No branches or pull requests

4 participants