Project

General

Profile

Feature #1269

create CMake variable for x86

Added by Mark Abraham over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
build system
Target version:
Difficulty:
uncategorized
Close

Description

Currently gmx_cpuid and the CUDA setup both try to find out if they are on x86, and do so slightly differently. I think we should unify this logic before it spreads further.

The only reliable way to detect this is to ask the compiler what architecture it is targetting. CMake itself refuses to get involved. GMX_X86_SSE2 is not an acceptable proxy, because you might be on ARM, or be wanting no acceleration.

I suggest we create a CMake variable GMX_IS_X86, and compile a test function in CMake that uses the #ifdefs from gmx_cpuid to avoid emitting an #error. Successful compilation will signal x86.

That CMake variable configures a #define in src/config.h.cmakein so the rest of the code can have the information. When CMake compiles the gmx_cpuid code for the acceleration detection, I believe we can pass a compiler define there, so that it can also test for #ifdef GMX_IS_X86.

Associated revisions

Revision eef36258 (diff)
Added by Mark Abraham almost 6 years ago

Rename GMX_IS_* to GMX_TARGET_*

This addresses some confusion that developed between release-4-6 and
master with me trying to develop the kernels in master branch so I
could have unit testing support, and then cherry-pick them back. I
had intended to solve #1269 in a separate commit, but it didn't happen
that way.

As #1269 discusses, the code sometimes needs to know what architecture
is being targetted by the compiler. This information is held in the
GMX_TARGET_X86 and GMX_TARGET_BGQ CMake and preprocessor
variables. Note that this information is distinct from what CPU
acceleration is being used (which might be "None" on either platform).

gmx_cpuid.c needs GMX_TARGET_X86 defined to work correctly on x86, and
is called at configure time (at which time config.h is
unavailable). So, this in CMake is treated via a command-line
definition of GMX_TARGET_X86 when required.

Fixes #1269 (even though I98c5791ec silently did this already)

Change-Id: I94e0756856e7d49ff09a87b8283189976b48ea49

History

#1 Updated by Mark Abraham about 6 years ago

  • Tracker changed from Bug to Feature
  • Status changed from New to Fix uploaded

#2 Updated by Mark Abraham almost 6 years ago

  • Status changed from Fix uploaded to Resolved
  • Target version changed from 5.0 to 4.6.4

#3 Updated by Mark Abraham almost 6 years ago

Fix snuck in in 25eb0e14db996feb, unfortunately. Pending fix to change to GMX_TARGET_* in https://gerrit.gromacs.org/#/c/2718/

#4 Updated by Mark Abraham almost 6 years ago

  • % Done changed from 0 to 100

#5 Updated by Mark Abraham almost 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF