Page MenuHomePhabricator

[AIX][llvm][support] Implement getHostCPUName
ClosedPublic

Authored by daltenty on Feb 3 2021, 12:06 PM.

Details

Summary

We implement getHostCPUName() for AIX via systemcfg interfaces since access to the processor version register is a privileged operation. We return a value based on the current processor implementation mode.

This fixes the cpu detection used by clang for -mcpu=native.

Diff Detail

Unit TestsFailed

TimeTest
330 msx64 debian > libarcher.races::task-dependency.c
Script: -- : 'RUN: at line 13'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -g -O1 -fsanitize=thread -I /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -Wl,-rpath,/mnt/disks/ssd0/agent/llvm-project/build/lib /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-dependency.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-dependency.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/deflake.bash /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-dependency.c.tmp 2>&1 | tee /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-dependency.c.tmp.log | /mnt/disks/ssd0/agent/llvm-project/build/./bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-dependency.c
270 msx64 debian > libarcher.races::task-taskgroup-unrelated.c
Script: -- : 'RUN: at line 13'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -g -O1 -fsanitize=thread -I /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -Wl,-rpath,/mnt/disks/ssd0/agent/llvm-project/build/lib /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-taskgroup-unrelated.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskgroup-unrelated.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/deflake.bash /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskgroup-unrelated.c.tmp 2>&1 | tee /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskgroup-unrelated.c.tmp.log | /mnt/disks/ssd0/agent/llvm-project/build/./bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-taskgroup-unrelated.c
250 msx64 debian > libarcher.races::task-taskwait-nested.c
Script: -- : 'RUN: at line 13'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -g -O1 -fsanitize=thread -I /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -Wl,-rpath,/mnt/disks/ssd0/agent/llvm-project/build/lib /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-taskwait-nested.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskwait-nested.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/deflake.bash /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskwait-nested.c.tmp 2>&1 | tee /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-taskwait-nested.c.tmp.log | /mnt/disks/ssd0/agent/llvm-project/build/./bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-taskwait-nested.c
300 msx64 debian > libarcher.races::task-two.c
Script: -- : 'RUN: at line 13'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -g -O1 -fsanitize=thread -I /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -Wl,-rpath,/mnt/disks/ssd0/agent/llvm-project/build/lib /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-two.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-two.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/deflake.bash /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-two.c.tmp 2>&1 | tee /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/races/Output/task-two.c.tmp.log | /mnt/disks/ssd0/agent/llvm-project/build/./bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/races/task-two.c
270 msx64 debian > libarcher.task::task-barrier.c
Script: -- : 'RUN: at line 15'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -g -O1 -fsanitize=thread -I /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -Wl,-rpath,/mnt/disks/ssd0/agent/llvm-project/build/lib /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/task/task-barrier.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/task/Output/task-barrier.c.tmp -latomic && env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1' /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/task/Output/task-barrier.c.tmp 2>&1 | tee /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/tools/archer/tests/task/Output/task-barrier.c.tmp.log | /mnt/disks/ssd0/agent/llvm-project/build/./bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/openmp/tools/archer/tests/task/task-barrier.c
View Full Test Results (13 Failed)

Event Timeline

daltenty created this revision.Feb 3 2021, 12:06 PM
daltenty requested review of this revision.Feb 3 2021, 12:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 12:06 PM
daltenty edited the summary of this revision. (Show Details)Feb 3 2021, 12:50 PM
llvm/lib/Support/Host.cpp
1236

I think the interfaces from sys/systemcfg.h can be used?

daltenty planned changes to this revision.Feb 3 2021, 1:43 PM
daltenty added inline comments.
llvm/lib/Support/Host.cpp
1236

Thanks, I'll check those out! I was having some trouble finding a documented system interface to get the same functionality, would definitely be preferable if possible.

daltenty updated this revision to Diff 321433.Feb 4 2021, 8:01 AM
  • Use systemcfg interfaces instead. Move the getsysttype call to the test.
daltenty edited the summary of this revision. (Show Details)Feb 4 2021, 8:02 AM
daltenty updated this revision to Diff 321436.Feb 4 2021, 8:08 AM
  • Remove stray program.h
stevewan added inline comments.Feb 4 2021, 12:00 PM
llvm/lib/Support/Host.cpp
1233

I suspect we're going to update this once POWER_10 is defined by the system header, do we need a TO-DO before that happens?

1238

Might be a dumb question, but why do we need the enum and can't do

switch (_system_configuration.implementation) {
case POWER_4:
...
daltenty added inline comments.Feb 4 2021, 1:30 PM
llvm/lib/Support/Host.cpp
1238

The original thinking was to benefit from -Wswitch-enum if someone missed something, but to be honest it just likely we'd miss it there, so I think we can just simply this as suggested.

daltenty marked an inline comment as done.Feb 4 2021, 1:30 PM
daltenty updated this revision to Diff 321558.Feb 4 2021, 1:31 PM
  • Simplify
  • Comment
llvm/lib/Support/Host.cpp
1228–1233

I'm not entirely sure that "something is better than nothing" is necessarily true here for these. All three have variant implementations/modes (e.g., ppc970, pwr5x, pwr6e) that we aren't handling here.

daltenty added inline comments.Feb 5 2021, 7:13 AM
llvm/lib/Support/Host.cpp
1228–1233

For pwr5x and pwr6e (IIUC don't think we can actually encounter ppc970), looking at the interfaces it seems that AIX won't distinguish the implementation mode, so I'm not sure if we can easily refine this in those case. Presumably this will still be better than returning 'generic' in those cases though though.

daltenty added inline comments.Feb 5 2021, 8:13 AM
llvm/lib/Support/Host.cpp
1228–1233

(Or rather ppc970 would presumable appear as POWER 4)

llvm/lib/Support/Host.cpp
1228–1233

What I was able to find internally seems to be that the _system_configuration.version field is PV_4_3 for ppc970, PV_5 exactly for pwr5 (and otherwise indicates pwr5x), and PV_6_Compat exactly for pwr6 (i.e., architected mode; and, if not exactly that value, indicates pwr6e).

Note that this does make sense with the historical background that POWER 6 went out with new instructions that were not going to be enshrined into the ISA going forward.

daltenty updated this revision to Diff 322171.Feb 8 2021, 11:00 AM
  • Handle specialized cases for pwr 4/5/6
daltenty updated this revision to Diff 322182.Feb 8 2021, 11:48 AM
  • Fix formatting

LGTM with minor comments on the test.

llvm/unittests/Support/Host.cpp
436

Minor comment wording/formatting nits.

455

Minor nit: Format as English prose (especially since there's already a period at the end).

458–459

... or rtrim.

459

Use drop_back

This revision is now accepted and ready to land.Feb 9 2021, 7:58 AM
stevewan added inline comments.Feb 9 2021, 9:17 AM
llvm/lib/Support/Host.cpp
1228–1233

PV_6_Compat exactly for pwr6 (i.e., architected mode; and, if not exactly that value, indicates pwr6e).

Noted that the accepted change returns pwr6x instead of pwr6e for versions not matching PV_6_Compat. Do we have a reasoning for that?

daltenty added inline comments.Feb 9 2021, 10:43 AM
llvm/lib/Support/Host.cpp
1228–1233

Good question. This what it appears to be called for LLVM in PPC.td. Why this is the case, I'm not too sure. It's close to what GCC uses (i.e. 'power6x') but our options appear to be incompatible anyway, since we use shortnames and they use long ones, so there's probably a follow on item here if we wanted all the variants of a name to be accepted.

llvm/lib/Support/Host.cpp
1228–1233

pwr6x is a suboption name used by Clang (probably based on GCC's power6x). The latter is documented as mainly being about the mffgpr and mftgpr opcodes. This would therefore map to the pwr6e suboption name used by IBM XL. See https://reviews.llvm.org/D58128 for more information.

daltenty updated this revision to Diff 322478.Feb 9 2021, 12:57 PM
  • Address comments
daltenty marked 4 inline comments as done.Feb 9 2021, 1:09 PM
daltenty retitled this revision from [AIX][support] Implement getHostCPUName to [AIX][llvm][support] Implement getHostCPUName.Feb 9 2021, 1:28 PM
This revision was landed with ongoing or failed builds.Feb 9 2021, 1:30 PM
This revision was automatically updated to reflect the committed changes.
stevewan added inline comments.Feb 9 2021, 2:39 PM
llvm/lib/Support/Host.cpp
1228–1233

Gotcha. So it's just called differently by different compilers, but in the end they are both associated with the "raw mode" of power6.