Isolated inlined C code into source and header files#1699
Isolated inlined C code into source and header files#1699z5146542 wants to merge 17 commits intoherd:masterfrom
Conversation
There was a problem hiding this comment.
Thanks Simon, please squash all commits into a single one.
I notice there are three types of drivers: C, XCode and Shell. I tried running a test using presi and driver shell and it is unable to link the barrier.o.
I used the following to test:
./herdtools7/_build/install/default/bin/litmus7 -v -set-libdir ./herdtools7/litmus/libdir/ -mach aarch64 -a 1 -s 100 -r 100 ./herdtools7/herd/tests/instructions/AArch64/A04.litmus -driver shell -mode presi -o ./kvm-unit-tests/A014
It’s unclear what driver shell is for, but if we keep it, this PR should work across all driver types (C/XCode/Shell).
Could you tell me why there is a need for a separate lib folder for barrier files?
|
Thanks for the comment, and thanks for catching the For now, I created a separate ...ensures that all C files generated by Regarding squashing commits, I will get this fixed very soon. |
|
@diaolo01 I have now isolated all inlined C files, and I have squashed all the commits. Please let me know if the changes look all good. |
relokin
left a comment
There was a problem hiding this comment.
$ make litmus-cata-aarch64-test-presi
fails, can you please have a look.
|
@relokin Thanks for this. The issue is now fixed. |
diaolo01
left a comment
There was a problem hiding this comment.
I tried running make litmus-aarch64-test and I am getting all sorts of errors. Mostly to do with inclusion and definition of the right headers. Please, can you look into it? You mentioned you were able to successfully run this on your end. If that is the case, I can share my local errors.
General minor comment: all lines
"Copyright year-present Institut National de Recherche en Informatique et "
Need to be
"Copyright 2026-present Institut National de Recherche en Informatique et "
41bef5d to
2dd8205
Compare
|
@diaolo01 Thanks for this. all the cata-aarch64-kvm-related cases should compile without errors now. |
|
Hi @diaolo01, I have fixed the
|
remove the template file for now litmus now isolates shared files to a shared library directory platform_io source and header is now also copied to shared library platform_io copy works correctly now progress on inline porting removed duplicate copy methods and fixed aarch64 std mode makefile config fixed x86_64 makefile config fixed confs isolated inlined barrier code fixed makefile config fixed issue with makefile on shell mode isoated all inlined files reverted changes relating to isolating config some minor changes some minor changes
potential fix to instruction port problem fixed aarch64 std and presi instruction.h error fixed kvm self mode compilation error added missing header fixed kvm self mode compilation error kvm-self.h fixed self.h dependency issue added kvm headers for fix fixed header issue getret added kvm-self.h fixed self.h dependency issue getret added
…d readability of some code
remove the template file for now litmus now isolates shared files to a shared library directory platform_io source and header is now also copied to shared library platform_io copy works correctly now progress on inline porting removed duplicate copy methods and fixed aarch64 std mode makefile config fixed x86_64 makefile config fixed confs isolated inlined barrier code fixed makefile config fixed issue with makefile on shell mode isoated all inlined files reverted changes relating to isolating config some minor changes some minor changes
potential fix to instruction port problem fixed aarch64 std and presi instruction.h error fixed kvm self mode compilation error added missing header fixed kvm self mode compilation error kvm-self.h fixed self.h dependency issue added kvm headers for fix fixed header issue getret added kvm-self.h fixed self.h dependency issue getret added
…d readability of some code
| /* Nikos Nikoleris, Arm Limited. */ | ||
| /****************************************************************************/ | ||
| #include <kvm-self.h> | ||
| #include <_find_ins.h> |
There was a problem hiding this comment.
if this is going to be a real header file should we remove the _?
There was a problem hiding this comment.
I tried to preserve the file names as much as possible for now, but if you think that these files should be renamed I will do so.
relokin
left a comment
There was a problem hiding this comment.
I think we have to be a little more careful about the copyright headers. Especially in cases where you don't introduce it, there is no need to change it.
There was a problem hiding this comment.
do we need this to be different to kvm-self.c?
There was a problem hiding this comment.
I'm not sure. These two files existed separately to begin with, so I only made minimal changes to both files.
There was a problem hiding this comment.
is this now a file that is both a standalone header and we might also inline?
There was a problem hiding this comment.
it is a standalone header yes. instruction.h is now no longer inlined.
relokin
left a comment
There was a problem hiding this comment.
There are still cases where litmus won't work, for example:
- litmus7 fails when I run a test directly:
$> litmus7 catalogue/aarch64/tests/MP.litmus
/var/folders/cl/7m7_nx7j0yn5tnsnwydtglcr0000gn/T/dir47895d.tmp/MP.c:114:10: fatal error: 'instruction.h' file not found
$> mkdir /tmp/t
$> litmus7 catalogue/aarch64/tests/MP.litmus -variant self -mode presi -a 4 -o /tmp/t
$> cd /tmp/t
$> make
....
MP.c:562:3: error: use of undeclared identifier 'cache_line_size'
562 | cache_line_size = getcachelinesize();
| ^~~~~~~~~~~~~~~
MP.c:562:21: error: call to undeclared function 'getcachelinesize'; ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
562 | cache_line_size = getcachelinesize();
| ^
2 errors generated.
make: *** [MP.s] Error 1
Independently, now we have some .c .h files which are still placed outside the libdir can we move them to the libdir?
There was a problem hiding this comment.
Can we please rename this to find_ins.h (remove the _)?
There was a problem hiding this comment.
Can we please rename this to hash.h (remove the _)?
There was a problem hiding this comment.
Can we please rename this to instance.h (remove the _)?
| @@ -1,2 +1 @@ | |||
| static size_t prelude_size(ins_t *p) { return find_ins(nop,p,0); } | |||
|
|
|||
| delay = 32 | ||
| makevar = AUXFLAGS=0x0 | ||
| makevar = SRCDIR=$(PWD)/.. | ||
| makevar = SRCDIR=$(CURDIR)/.. |
There was a problem hiding this comment.
can you please make a similar change to:
litmus/libdir/kvm-aarch64-qemu.cfg
litmus/libdir/kvm-armv8.1+rcpc.cfg
litmus/libdir/kvm-armv8.1.cfg:
litmus/libdir/kvm-armv8.5-a+memtag.cfg
litmus/libdir/kvm-m1.cfg
litmus/libdir/kvm-x86_64.cfg
| fnames | ||
|
|
||
| (* Reference to the shared library *) | ||
| let libdir = "lib/" |
There was a problem hiding this comment.
Can we please rename this to litmus?
| #include <../kvm-headers.h> | ||
|
|
||
| static void litmus_icache_sync(uintptr_t vaddr, uintptr_t vaddr_end) | ||
| static ins_t getret(void) { |
| /****************************************************************************/ | ||
| #include <kvm-self.h> | ||
| #include <_find_ins.h> | ||
| #include <../kvm-headers.h> |
There was a problem hiding this comment.
This is not great can we please move kvm-headers into the libdir?
This pull request now separates the inlined C code from the generated C code into a separate source and header file (e.g.,
barrier.candbarrier.h) respecitvely.Previosuly, when the C code is generated, all relevant files are created within the specified root directory:
Now, the generated C code results in the following:
For all tests included in the batch (e.g.
test1.candtest2.c),barrier.cis no longer inlined and is replaced with#include <barrier.h>. The same applies for most of the other inlined code.For some previously inlined functions and variables with dependencies based on specific test cases (e.g. functions depending on macros that may differ depending on the test cases), they remain static for the time being. The plan is to remove this dependency after this change is incorporated.