|
From: Florian K. <br...@ac...> - 2012-08-27 03:48:17
|
I'd like to auto-detect the cache configuration of the host machine for
s390. So I was looking around how this is done on other architectures.
Turns out, nobody does it except x86 and x86-64. These architectures get
special treatment in form of VG_(cpuid). But that function is not
portable to other architectures. On s390 I would need to know whether
the host supports a certain insn. That info is present in the "hwcaps"
field of VexArchInfo. But VexArchInfo is not passed to the tools.
Now what? I see two approaches.
(1) Pass VexArchInfo to the "instrument" function of the tool. That
structure would convey whether or not the cache configuration of
the host can be queried. A tool would then query that information
in an architecture-specific way. For instance, we could amend
VexArchInfo by adding a "Bool x86_amd64_has_cpuid" field. Cachegrind
would then call VG_(cpuid) if that field is True. VG_(has_cpuid)
would be obsolete.
(2) Replace VG_(cpuid) with, say, VG_(cache_info) which would return
information about the host's caches in a general way:
- number of cache levels
- for each cache level
- split data/insn cache or not
- line size
- cache size
- set associativity
Also replace VG_(has_cpuid) with VG_(has_cache_info).
So #2 moves all the architecture specific machinery for querying out of
the tools. It concentrates it in a single spot. Which is nice, should
there ever be more than one tool wanting that info. There is a bit of
work to provide the cache info in this proposed form, but I presume it
shouldn't be difficult to do.
#1 is of course less implementation work.
I do not have a strong preference either way. #2 seems to be the better
approach for the long term. But we can bite the bullet at the time when
another tool emerges which needs to know this stuff and for now just run
with #1 (which is what I would do).
Opinions, strong and otherwise are welcome.
Florian
|