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

Default enable SSE only if compiler supports it #514

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Dec 8, 2020

This fixes an issue seen in ROS Noetic where SSE is default enabled on
an aarch64 system. CMake seems to think the host supports SSE, but the
compiler does not.

I don't know the root cause of the issue. Maybe it's because the ROS 1 buildfarm uses qemu on x86 systems, and the method CMake uses to determine SSE support shows that the machine beneath qemu supports it?

Fixes #513


This change is Reviewable

This fixes an issue seen in ROS Noetic where SSE is default enabled on
an aarch64 system. CMake seems to think the host supports SSE, but the
compiler does not.

Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

:LGTM:

+@jamiesnape Could you take a once over on this one? It makes sense to me: ultiamtely, it distinguishes between what the *host* reports vs the *compiler*.

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jamiesnape)

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

Also :lgtm: with a question below. Would be great to get a quick look from @jamiesnape -- just a small change here.

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jamiesnape and @sloretz)


CMakeLists.txt, line 115 at r1 (raw file):

else()
  # Unset SSE_FLAGS so it doesn't get used in subdirectories
  set(SSE_FLAGS "")

Just curious -- @sloretz why unset this particular variable? Does it have some global meaning that other local variables like FCL_TARGET_SUPPORT_X64_SSE do not?

Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jamiesnape and @sloretz)


CMakeLists.txt, line 115 at r1 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

Just curious -- @sloretz why unset this particular variable? Does it have some global meaning that other local variables like FCL_TARGET_SUPPORT_X64_SSE do not?

That's funny. I had the same question, and then I realized he sets those flags based on host to perform a compiler test. The result of that test is stored in the _compiler_supports_sse variable. If we determine that the compiler doesn't support sse, we then need to clear that variable so it doesn't pollute, as the comment says, subdirectories CMakeLists.txt contexts.

I spent a brief moment considering if a different articulation of the logic would eliminate the need to clear these flags again, but decided there probably isn't (or, at least, not obviously). It's rendered somewhat confusing because there are a numb of SSE related symbols all churning around.

Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jamiesnape)

Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jamiesnape)

Copy link
Contributor

@jamiesnape jamiesnape left a comment

Choose a reason for hiding this comment

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

This code is getting really ugly (not the fault of he author of this PR) and I wonder whether a library should ever be setting SSE flags, but aside from my comment the code is an improvement, so :lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)


CMakeLists.txt, line 115 at r1 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

Just curious -- @sloretz why unset this particular variable? Does it have some global meaning that other local variables like FCL_TARGET_SUPPORT_X64_SSE do not?

Looks like it is used in src/CMakeLists.txt. Not sure why we are setting it globally and per-target, however. I think I would wrap the usage there with if(FCL_USE_X64_SSE) ... endif() if it is not already set.

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)


CMakeLists.txt, line 115 at r1 (raw file):

Previously, jamiesnape (Jamie Snape) wrote…

Looks like it is used in src/CMakeLists.txt. Not sure why we are setting it globally and per-target, however. I think I would wrap the usage there with if(FCL_USE_X64_SSE) ... endif() if it is not already set.

Oh, I see. A cleaner alternative might be not to use SSE_FLAGS here to hold the proposed flags -- how about using a local variable like _proposed_sse_flags and then set SSE_FLAGS only if the host and compiler tests both pass?

@sloretz
Copy link
Contributor Author

sloretz commented Dec 9, 2020

Just curious -- @sloretz why unset this particular variable? Does it have some global meaning that other local variables like FCL_TARGET_SUPPORT_X64_SSE do not?

No special meaning other than it's used in src/CMakeLists.txt

Looks like it is used in src/CMakeLists.txt. Not sure why we are setting it globally and per-target, however. I think I would wrap the usage there with if(FCL_USE_X64_SSE) ... endif() if it is not already set.

Yup, link below:

target_compile_options(${PROJECT_NAME} PUBLIC ${SSE_FLAGS})

Oh, I see. A cleaner alternative might be not to use SSE_FLAGS here to hold the proposed flags -- how about using a local variable like _proposed_sse_flags and then set SSE_FLAGS only if the host and compiler tests both pass?

I'm happy to make any changes to the logic there's consensus on.

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

Thoughts @jamiesnape & @SeanCurtis-TRI ?

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)

Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

I do like the idea of setting a local variable with the flags and only setting SSE_FLAGS if we mean to do so. The "set-and-unset-as-necessary" paradigm would be a bit brittle. That said, is it worth it? After all, it's one small rock on top of a pile of ugly rocks. The real thing would be to have someone at @jamiesnape's level actually go through and make this sane.

Conclusion: I'm content to take it as is (having passed CI) and defer polishing the rock to later.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)

Copy link
Contributor

@jamiesnape jamiesnape left a comment

Choose a reason for hiding this comment

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

Let's merge then. This is not the biggest problem with the build system.

I probably will have some time at some point to redesign the build for modern CMake. Really the build on this project should be clean and simple (one library, some tests, and relatively few dependencies); it has just grown organically over a very long time trying to support old versions of CMake and many versions of third--party dependencies. That support is probably no longer needed, which will make cleaning up fairly quick.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)

Copy link
Contributor

@SeanCurtis-TRI SeanCurtis-TRI left a comment

Choose a reason for hiding this comment

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

Sounds like something to look forward to.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sloretz)

@SeanCurtis-TRI SeanCurtis-TRI merged commit da07e5b into flexible-collision-library:master Dec 11, 2020
@rhaschke
Copy link

@sloretz, I'm going to prepare a new ROS release.

@sloretz sloretz deleted the does_compiler_have_sse_support branch December 14, 2020 18:19
@jamiesnape jamiesnape removed their assignment Jun 22, 2021
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.

Build failure on ARM (ROS Noetic release issue)
5 participants