Skip to content

TTG/building system#424

Merged
bosilca merged 1 commit intoICLDisco:masterfrom
therault:ttg/building-system
Nov 4, 2022
Merged

TTG/building system#424
bosilca merged 1 commit intoICLDisco:masterfrom
therault:ttg/building-system

Conversation

@therault
Copy link
Copy Markdown
Contributor

These commits are the ones missing for TTG support, which uses PaRSEC as a submodule.

There is one commit that still needs to be considered (not part of this PR):

352014fdbf10a141fe9f4eab7e70cac6949e638d [Restore the C11 support broken in 694d1e9 and few other things]. I think it was a backport from the master, but too many things have changed to make sure.

-- We need to check if this is still needed (or what parts of it are needed).

@therault therault requested a review from a team as a code owner August 19, 2022 20:37
@therault therault force-pushed the ttg/building-system branch 2 times, most recently from fb55ce7 to 562fbeb Compare August 19, 2022 20:58
Comment thread parsec/parsec_internal.h
parsec_execution_stream_t *es,
const parsec_task_t* task);
typedef int (parsec_update_dependency_fn_t)(parsec_taskpool_t *tp,
const parsec_task_t* restrict task,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious: why remove the restrict here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because this .h file is pulled in by parsec/ttg.h, and restrict is a keyword that is refused by g++ and/or other C++ compilers, even if the declaration is within an extern "C" { ... } block. At least, this is what I remember of this issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahh right, we need the header for parsec_task_s (and probably some other things). It's a bit ironic that an external project includes parsec_internal.h though ^^

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Some things will probably need cleaning, but I wouldn't say TTG is 'external' from PaRSEC... There is a shade area here :)

Copy link
Copy Markdown
Contributor

@bosilca bosilca Aug 27, 2022

Choose a reason for hiding this comment

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

I don't think the right approach is to remove this optimization keyword. Instead I would propose we protect restrict in parsec_config or parsec_config_bottom for C++ case, and leave it's usages in the C library as intended originally.

/* If we're in C++, redefine restrict to nothing */
#if defined(c_plusplus) || defined(__cplusplus)
#  undef restrict
#  define restrict
#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The macro trick is now implemented.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This undef of the macro will have side effects on users that include parsec.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, it will have a side effect only if the users are using a C++ compiler...

According to stackoverflow, some C++ compilers do support restrict or __restrict__... And others don't.
I guess we should have some CMake logic to decide if HAVE_RESTRICT or not, and have a corresponding cmakedefine.

CMake has a c_restrict low-level C compiler feature testable via target_compile_features, but there is no such thing in the C++ compiler feature set. I could try to compile some code with restrict with the C++ compiler to see if it's supported. But the macro we define would need to be conditional to the type of compiler anyway.

Comment below if you think I should implement this solution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does anyone remember why restrict was added in the first place? We don't use it in other places where tp and tasks are passed, so maybe dropping it here is just ok?

Copy link
Copy Markdown
Contributor

@abouteiller abouteiller Nov 3, 2022

Choose a reason for hiding this comment

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

This is a function pointer and it cannot be inlined, so we could keep it on the C file (implementation), and remove it from this interface; as long as the compiler doesn't barf on the incompatible function type signatures I don't see what good the restrict does here.

Comment thread tests/CMakeLists.txt
Comment thread CMakeLists.txt Outdated
Comment thread cmake_modules/FindHWLOC.cmake
Comment thread cmake_modules/FindHWLOC.cmake
Comment thread tests/CMakeLists.txt
@bosilca bosilca added this to the v4.0 milestone Oct 12, 2022
@therault therault force-pushed the ttg/building-system branch from 97762f8 to 81b6f4e Compare November 2, 2022 17:48
Comment thread parsec/include/parsec/parsec_config_bottom.h Outdated
@bosilca
Copy link
Copy Markdown
Contributor

bosilca commented Nov 4, 2022

Let's get this done. I agree with @abouteiller comment, restrict has little meaning in the function prototype, other than forcing all functions to support it. Instead, we can add it to the function implementation, allowing the compiler to do optimizations. Also, please squash all the commits into one or two (no more commits with revert).

…e (restrict), protect some additional header files for C++

- Force PIC when compiling libparsec, even if it is static.

  libttg.so links with libparsec.a... To allow this kind of behavior,
  libparsec must be compiled in position independent code, even when
  compiling it statically.

- Some Fixes to hwloc detection

Signed-off-by: Thomas Herault <herault@icl.utk.edu>
signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>

- Do not build the test target if parsec is used as a submodule

  This is important for TTG, as the 'tests' goal gets overloaded,
  when parsec is used as a submodule of TTG

  Tests building is still not added to the target 'all' if parsec is
  not the root project, but the parsec_addtest_cmd keeps doing the
  add_test inconditionally

- Fix a typo introduced by cherry-picking very different versions

- Fix paths and other typos in compiler tests that are supposed to fail, so they fail for the right reason. Revert unproductive changes in CMakeLists.txt

- Missing variable initialization in user trigger termination detection, when in debug mode

- Use a macro in the PARSEC namespace to solve the restrict issue.

With this approach,

  - if the user code is C, its compiler must be C99 compliant, and
    restrict should be defined

  - if the user code is C++, the user compiler might support restrict
    or not, and we have no way to know that at the time we compile
    PaRSEC (because the user might use another C++ compiler than the
    one we detect). TTG, for one, requires to include parsec_internal.h,
    so in this case we make sure restrict doesn't appear in the
    prototype of these functions.

What we don't lose:
  - the C99 compiler sees the restrict keywords and can generate
    optimized code for the implementation of the corresponding
    functions.
  - We don't have side effects on the user code, even in the C++
    case (if the user defines a variable named 'restrict' for
    example, or if the user's compiler supports the keyword
    restrict and they used it in other places).
What we lose:
  - the C++ compiler doesn't see the restrict keyword, even if it
    supports it, so if the user passes, by mistake, overlaping
    pointers, their compiler will not issue a warning/error.
@therault therault force-pushed the ttg/building-system branch from 5881a03 to 08964d3 Compare November 4, 2022 13:30
@therault
Copy link
Copy Markdown
Contributor Author

therault commented Nov 4, 2022 via email

@bosilca bosilca merged commit fcba4b3 into ICLDisco:master Nov 4, 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

Successfully merging this pull request may close these issues.

4 participants