Skip to content

Conversation

@alberto-scolari
Copy link
Contributor

@alberto-scolari alberto-scolari commented Jan 31, 2024

This issue is solved by:

  1. building static libraries as Position Independent code
  2. add flag --alp-link-dynamic to link dynamic ALP libraries

@alberto-scolari alberto-scolari changed the base branch from master to develop January 31, 2024 15:15
@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch from a963723 to 4828c0b Compare January 31, 2024 15:16
@anyzelman anyzelman added this to the v0.8 milestone Feb 5, 2024
@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch from 2c96fad to c07d450 Compare February 5, 2024 15:22
@alberto-scolari alberto-scolari self-assigned this Feb 14, 2024
@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch from aee7226 to 409b0a8 Compare February 14, 2024 16:47
@alberto-scolari alberto-scolari marked this pull request as ready for review February 14, 2024 16:47
Copy link
Member

@anyzelman anyzelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor comment, and a question: is there someone else besides you who could review the cmake changes? I'm not an expert at it myself and may miss some finer points of changes there

@alberto-scolari
Copy link
Contributor Author

alberto-scolari commented Feb 15, 2024

Only a minor comment, and a question: is there someone else besides you who could review the cmake changes? I'm not an expert at it myself and may miss some finer points of changes there

Kindly inviting @byjtew to chime in and inspect the CMake changes

byjtew
byjtew previously approved these changes Feb 15, 2024
@anyzelman
Copy link
Member

anyzelman commented Feb 15, 2024

Manual tests detect an issue with the grbcxx script-- both static and shared run into missing symbols:

$ cd build
$ git checkout 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries 
Switched to branch '171-grbcxx-when-performing-shared-linking-still-selects-static-libraries'
Your branch is up to date with 'github/171-grbcxx-when-performing-shared-linking-still-selects-static-libraries'.
$ make -j88 install
[..]
$ /scratch/grb-mpich-install/bin/grbcxx -b reference_omp -I../tests/ ../tests/smoke/simple_pagerank.cpp 
/usr/bin/ld: /tmp/cc2p7jso.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::~MatrixFileIterator()':
simple_pagerank.cpp:(.text._ZN3grb5utils8internal18MatrixFileIteratorIjvED2Ev[_ZN3grb5utils8internal18MatrixFileIteratorIjvED5Ev]+0x25): undefined reference to `ReadEdgeEnd'
/usr/bin/ld: /tmp/cc2p7jso.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::operator++()':
simple_pagerank.cpp:(.text._ZN3grb5utils8internal18MatrixFileIteratorIjvEppEv[_ZN3grb5utils8internal18MatrixFileIteratorIjvEppEv]+0x177): undefined reference to `ReadEdge'
/usr/bin/ld: /tmp/cc2p7jso.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::start() const':
simple_pagerank.cpp:(.text._ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv[_ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv]+0x12e): undefined reference to `ReadEdgeBegin'
/usr/bin/ld: simple_pagerank.cpp:(.text._ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv[_ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv]+0x1ef): undefined reference to `ReadEdgeBegin'
collect2: error: ld returned 1 exit status
$ /scratch/grb-mpich-install/bin/grbcxx --link-alp-static -b reference_omp -I../tests/ ../tests/smoke/simple_pagerank.cpp 
/usr/bin/ld: /tmp/ccFxTCMA.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::~MatrixFileIterator()':
simple_pagerank.cpp:(.text._ZN3grb5utils8internal18MatrixFileIteratorIjvED2Ev[_ZN3grb5utils8internal18MatrixFileIteratorIjvED5Ev]+0x25): undefined reference to `ReadEdgeEnd'
/usr/bin/ld: /tmp/ccFxTCMA.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::operator++()':
simple_pagerank.cpp:(.text._ZN3grb5utils8internal18MatrixFileIteratorIjvEppEv[_ZN3grb5utils8internal18MatrixFileIteratorIjvEppEv]+0x177): undefined reference to `ReadEdge'
/usr/bin/ld: /tmp/ccFxTCMA.o: in function `grb::utils::internal::MatrixFileIterator<unsigned int, void>::start() const':
simple_pagerank.cpp:(.text._ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv[_ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv]+0x12e): undefined reference to `ReadEdgeBegin'
/usr/bin/ld: simple_pagerank.cpp:(.text._ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv[_ZNK3grb5utils8internal18MatrixFileIteratorIjvE5startEv]+0x1ef): undefined reference to `ReadEdgeBegin'
collect2: error: ld returned 1 exit status

Following these steps (without the --link-alp-static option) does work for the develop branch

@anyzelman
Copy link
Member

Also the new --link-alp-static option should be documented somewhere -- I tried grbcxx --help, but that one just shows the standard CC help. (What lpfc{c,xx} does, fwiw, is print our own options, and then make the nested call to ${CC} --help)

@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch from 19c1225 to 273ddd5 Compare February 20, 2024 13:52
@anyzelman
Copy link
Member

Sorry, now a sort of reversed error as last week:

$ /scratch/grb-mpich-install/bin/grbcxx --link-alp-static -b reference_omp -I../tests/ ../tests/smoke/simple_pagerank.cpp
$ ls -lha ./a.out 
-rwxrwxr-x. 1 yzelman yzelman 543K Feb 20 18:18 ./a.out
$ ./a.out 
./a.out: error while loading shared libraries: libalp_utils.so: cannot open shared object file: No such file or directory

I suppose the libalp_utils should also be linked statically.

The default / dynamic linkage case is now behaving as expected:

$ /scratch/grb-mpich-install/bin/grbcxx -b reference_omp -I../tests/ ../tests/smoke/simple_pagerank.cpp
$ ls -lha ./a.out 
-rwxrwxr-x. 1 yzelman yzelman 531K Feb 20 18:19 ./a.out
$ ./a.out 
./a.out: error while loading shared libraries: libalp_utils.so: cannot open shared object file: No such file or directory
$ /scratch/grb-mpich-install/bin/grbrun -b reference_omp ./a.out
Usage: ./a.out <dataset> <direct/indirect> (inner iterations) (outer iterations) (solver iterations) (verification <truth-file>)
<dataset> and <direct/indirect> are mandatory arguments.
(inner iterations) is optional, the default is 1. If this integer is set to zero, the program will select a number of inner iterations that results in at least one second of computation time.
(outer iterations) is optional, the default is 10. This integer must be strictly larger than 0.
(solver iterations) is optional, the default is 1000. This integer must be strictly larger than 0.
(verification <truth-file>) is optional. The <truth-file> must point to a pre-computed solution that the computed solution will be verified against.

Only a minor thingy, in the help now available, the possible values could perhaps better go on a newline?

/scratch/grb-mpich-install/bin/grbcxx --help
* Compiles an ALP/GraphBLAS application by calling an underlying compiler and by passing needed flags.

USAGE: /scratch/grb-mpich-install/bin/grbcxx [ALP-specific options...] [--] <compiler arguments...>

ALP-specific options:
  -b,--backend <backend>  compile against the ALP/GraphBLAS backend <backend>; possible values: reference reference_omp hyperdags nonblocking bsp1d hybrid; default: reference
  --link-alp-static       link the specified ALP/GraphBLAS backend statically (default linking is dynamic)
  --show                  show the full compilation command WITHOUT executing it
  --version               display the current ALP/GraphBLAS version
  --help                  display this help
  -- <args...>            pass all the following <args...> arguments directly to the underlying compiler

* Selected backend: reference
* Underlying compiler: /usr/bin/c++
* Underlying compiler help:

Usage: c++ [options] file...
...

@anyzelman
Copy link
Member

Also (sorry for piling up minor issues): if grbcxx has a --help, should grbrun not also?

@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch 2 times, most recently from 36364c5 to cb61f5f Compare February 21, 2024 10:42
@alberto-scolari
Copy link
Contributor Author

Also (sorry for piling up minor issues): if grbcxx has a --help, should grbrun not also?

Yes, it was implemented alongside the --help for grbcxx. The last commits should fix all reported issues.

@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch 3 times, most recently from 607e6ef to 790c3ac Compare February 26, 2024 11:03
@alberto-scolari alberto-scolari force-pushed the 171-grbcxx-when-performing-shared-linking-still-selects-static-libraries branch from 790c3ac to 2d0a4b6 Compare March 7, 2024 16:33
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.

grbcxx when performing shared linking still selects static libraries

4 participants