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

Make the CommsUtils functions inline #21

Merged
merged 6 commits into from
Mar 25, 2017

Conversation

martin-ueding
Copy link
Contributor

@martin-ueding martin-ueding commented Dec 1, 2016

I tried to compile the current QPhiX devel branch
(b1dbed4) together with the current
Chroma devel branch (62cf4d341f5e4811637d37e54a9345598faea848). This has
failed due to multiple definition errors like this:

../../lib/libchroma.a(syssolver_mdagm_aggregate.o): In function `QPhiX::CommsUtils::sumDouble(double*)':
syssolver_mdagm_aggregate.cc:(.text+0x180): multiple definition of `QPhiX::CommsUtils::sumDouble(double*)'
../../lib/libchroma.a(syssolver_linop_aggregate.o):syssolver_linop_aggregate.cc:(.text+0x1d0): first defined here

Drilling down into QPhiX I noticed that the file include/comm.h is the
only source of a definition for this function. There are three
preprocessor branches that are in this file. I have added a sentinel in
the previous commit such that one cannot mess it up.

The culprit seems to be that the function definitions are not inline.
Having a member function defined within the class automatically makes
it inline. Those are no problem in the header. The functions in question
however are only free functions in a namespace. Their definition in the
header does not automatically make them inline, yielding to a multiple
definition error as seen.

I opted for adding inline as those functions just delegate to QDP++ if
they do anything at all. The other way would be to split off the
definition form the declaration into a .cc file.

I tried to compile the current QPhiX devel branch
(b1dbed4) together with the current
Chroma devel branch (62cf4d341f5e4811637d37e54a9345598faea848). This has
failed due to multiple definition errors like this:

../../lib/libchroma.a(syssolver_mdagm_aggregate.o): In function `QPhiX::CommsUtils::sumDouble(double*)':
syssolver_mdagm_aggregate.cc:(.text+0x180): multiple definition of `QPhiX::CommsUtils::sumDouble(double*)'
../../lib/libchroma.a(syssolver_linop_aggregate.o):syssolver_linop_aggregate.cc:(.text+0x1d0): first defined here

Drilling down into QPhiX I noticed that the file `include/comm.h` is the
only source of a definition for this function. There are three
preprocessor branches that are in this file. I have added a sentinel in
the previous commit such that one cannot mess it up.

The culprit seems to be that the function definitions are not inline.
Having a member function defined within the `class` automatically makes
it inline. Those are no problem in the header. The functions in question
however are only free functions in a namespace. Their definition in the
header does not automatically make them inline, yielding to a multiple
definition error as seen.

I opted for adding `inline` as those functions just delegate to QDP++ if
they do anything at all. The other way would be to split off the
definition form the declaration into a `.cc` file.
@bjoo
Copy link
Contributor

bjoo commented Dec 1, 2016 via email

@martin-ueding
Copy link
Contributor Author

Would it make sense to rename the devel branch to master and drop the old master branch in Chroma, QDP++ and QPhiX, then? Or perhaps the devel should be merged into master whenever it is stable enough to compile?

I can currently not test whether switching QDP++ from master to devel will remove this issue here. I mean the code in question is QPhiX devel, so I think the patch is still neded. When the Intel Xeon cluster is back online, I can test it and provide an update.

My mental picture of all this software is still a bit blurry. Do I understand it correctly that QPhiX provides Dslash and solvers and that I can choose the Dslash from QPhiX or cpp_wilson_dslash (barring a complication with QDP++ and QDP-JIT)? If I choose neither of them, does Chroma (or QDP++) has a “default”/“fallback” solver and Dslash implemented? When using Chroma, QDP++, and QPhiX, do I have to adjust the input XML to benefit from QPhiX or will hmc resolve CG_INVERTER to the best implementation that has been compiled into hmc?

@martin-ueding
Copy link
Contributor Author

The issue still persists with the devel branches. I tried to bootstrap a Chroma installation with QPhiX and QDP++ on Intel Xeon Haswell today and on Intel i5 Sandy Bridge yesterday. The functions are still duplicated somewhere in libchroma.a.

Can you get this build correctly without inlining the functions?

@martin-ueding
Copy link
Contributor Author

I currently try to get Chroma running on the Marconi (Intel KNL) cluster in Italy. There I have the exact same linker error in libchroma.a when using the devel versions of Chroma, QDP++, and QPhiX. This patch is needed for me to get it to compile.

I truly do not understand how it compiles on your machines. Since those functions are non-member non-template functions implemented in the header, there must be linker errors. This also happens with GCC and Intel C++ on three different machines now.

Could this please be included in the canonical devel branch?

I have forgotten to add the header for the exception. It has built on my
machine with GCC 6.3 but failed when testing with GCC 4.9 on Travis CI.
This adds the missing header.
@martin-ueding martin-ueding merged commit e5ed350 into JeffersonLab:devel Mar 25, 2017
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.

2 participants