Hello, this is a very basic talk for people who know Coxinel, who knows Coxinel in this room,
who uses Coxinel in this room.
Can we do something about?
All right, good.
Nice.
So Coxinel for those who, for the few who don't know,
has, is a, is an engine for matching and matching c-code.
And it's all, it has an own AST, as well, apart from the first place.
An AST which is being built up on this.
So it has a notion of c and to a good extent c++.
And it allows first to match the entities of the c language
and then to enact changes.
So what is being called semantic patching or patching on those entities?
And it matches also matches and patches control flow as well.
So it's pretty powerful.
And it's very easy, has a very easy notation to use.
Yes, Coxinel originated around 20 years ago as a research to support.
The research to support the Linux kernel to besides bugs,
which are being originating from bad coding patterns.
It's a, when there are situations which you can spot more or less with a pattern,
some pattern in the code.
Coxinel is there coxinel, so a led bug is there for you.
In the kernel nowadays there are, I think, around 70 or so resident coxinel patches,
which run with, when you trigger, make coxie check.
So these are like static checks, static, static analyzer functionality of coxinel.
So it's not much of, let's say you also can get hints on how to code the,
change the, your code accordingly.
But many more patches are being used by module containers in order to update drivers or custom modules,
once new versions of Linux comes out.
I work in HPC, I perform as computing, I don't work on the kernel.
My interest is usually in helping scientists getting their code faster,
either by helping them giving a technique or a library or maybe doing it myself.
And the code patterns which are of my interest are around the APIs,
so the programming interfaces of libraries,
or notations which are called OpenMP or OpenECC or some others.
Focus is to support the parting of old codes to GPUs, to GPUs,
because it's not trivial for codes which are large exist in many years.
And then maybe don't have funding for providing them for scratch.
So parting can be useful, I could be, I mean,
we wish to be available solution for some of those.
And I'm also interested in to C++ related,
refactoring on changes with coxinel,
which were not in the first focus of coxinel,
as it was being conceived for C.
I think in an age of pollution in the physical sense,
yeah, many other senses,
were sublots and craft of all sorts present in the code,
can be worst being removed, clean up somehow,
at least detected, maybe with coxinel.
These are things which are of my interest,
which are a bit different if you see from what is of interest
to the main probability to the kernel community.
And you know, interest is also to speak about this,
to diffuse this knowledge in the HPC community
and if there is something good for coxinel,
also in the kernel community.
Who knows compiler explorer,
half of the room knows compiler explorer,
we use compiler explorer to view snippets
or to write snippets of code,
of compiler code and to get
assembly codes in output,
without having to have those different compilers,
which we can select here on our computer,
or those different machines,
which are platform of target set list,
supported,
and we can do this on many programming languages,
which we can select here.
So this is a website just for the ones who don't know it,
gotbought.org is the website,
and it's a useful tool for
programming, for checking programming,
programs, nips,
different, yeah, with different compilers,
different languages, yeah.
Good.
So compiler explorer has been written in a typescript
by Matt Rodbought.
It's a useful learning tool for training,
for doing trainings in C++, for instance,
for showing nips to other people,
like, hey, I did this,
and you can share,
as nips that you did,
you can show bugs to other people
that you found in the compilation of programs,
and it's also open to new compilers,
and new languages,
so the authors of compilers
experts accept contributions,
so that maybe we can contribute,
we can give access to coccinality here as well, somehow.
So, not an actual type script,
but still I tried a bit, playing with it,
and I came up with something like this.
So since as far as,
well,
in the first order of approximation,
without creating a separate window here,
because coccinality as we will see now,
works by having at least two inputs.
So a program which will write in the coccinality language,
the semantic patch language,
in an arbitrary amount of C++ code,
the code which we should match and batch.
So you would need at least two sections here.
I was in a hurry,
I just wanted to create a prototype,
just for checking the idea and sharing it with people.
So I resorted to the trick of having some EFTF here,
in a way that you could compile this whole thing here,
so you would write your C program up here,
you would write your coccinality rule,
because coccinality programs are code rules,
down here separated by this EFTF,
so this is the notation in order to separate it.
It's pretty primitive if you want,
but it does the job.
Okay, let's see,
for who doesn't know coccinality,
let this be a good moment to get a idea of it.
So here in this coccinality rule,
we remove a lot of occurrences of the literal zero,
and we wish to replace them with the literal one.
And the program here, which has just one occurrence
of the zero literal,
becomes gets patched to this.
What is the patch?
The patch is somewhere here in this hover at window.
Yeah, and this is the patched file.
Which is the new functionality with respect to coccinality.
Well, just that you can do this in a browser,
because we do like doing things in the browser in the last years,
and that more or less interactively,
as you finish typing here, you get the output here,
and therefore it's a learning tool.
Because it accelerates the loop of getting back the result of your actions.
Yeah, same story.
If you use the coccinality notation to match the constants,
so you create the meta variable constant C,
which is get instance that each time a constant is being
and counter it, and you want to wish to replace it,
so a plus line with the literal chart C,
zero becomes chart C here.
So this is just to give you the complete basics of coccinality.
Further, we have rules where you can modify symbols.
In this way here, we say that those symbols should be treated as identifiers,
and therefore all occurrences of A here
get replaced with bidder.
Further expressions can be matched,
so arbitrarily complicated expressions can be matched,
and replaced with context.
Here we are putting a minus and a plus in the middle of a set of a statement,
because coccinality is quite agnostic to a white space.
So this language here tolerates white space,
as long as you do a good job in putting the semi-colons where they belong.
What happens when you write something wrong,
like in the coccinality terms,
like this rule here, which is wrong,
you have to click at the moment you have to click here,
or simply look that the outcalls has six lines of a standard error.
This standard error is complete.
It's saying partial error in the coccinality rule.
Yeah, so this is the minimum to get some,
to understand something, what did you do wrong?
Yeah, this is the good way to do the patching from before,
from before.
The C++, as I said, we are working gradually,
so my focus is also in introducing C++,
from reporting the C++ changes,
who uses C++ to certain extent?
Ah, quite a lot of people, good.
So this is like one feature of C++ 23,
so multi-index bracket statements, or, sorry, accesses,
would.
Compiler explorer and by extension,
let's call it coccinality explorer,
can offer you a catalog of examples,
where not yet there.
And can load and save files to your system,
and if this gets into, yeah,
if this gets accepted,
this prototype into Compiler explorer,
we might have here like useful examples to learn
and practice coccinality,
perhaps we will get the window nicely split,
so we will see.
I think you can try already this.
There is a poor request here, being reviewed.
All it took to me was to install not JS version 20
and run this locally on my laptop,
and I could have this in the browser running,
and this was enough for me,
and some people which learned coccinality
were very happy of getting this.
So this is a proof of concept so far.
I wanted to probe with people like this,
primarily when teaching coccinality,
and very happy, yeah, of knowing from your what you think.
We have this ugly preprocessor trick at the moment
to separate the rule from the C program.
Maybe one day we will get a window in between,
windows splitting between.
I don't know if this can be easily supported by the backbone
of the code of Compiler Explorer,
also having like the tactical material here specific for this.
We don't have yet.
And we also don't have specific options
of the many options with coccinality.
I'm happy of getting feedback to tell me,
to tell us what could be useful here.
And so yeah.
So in order to use coccinality properly,
there is a coccinality training,
which I gave like one week ago,
with new material or the fresh material.
You get it here.
Yeah, this lights are already uploaded.
And this is very new.
I think the first ever coccinality cheat sheet.
So you will not learn coccinality from this,
but if you already know coccinality a bit,
I think this summarizes the important things
when you need them.
So I really recommend giving it a look,
and of course giving me feedback for improving it.
Yeah, at some point probably we will push it
into the coccinality augmentation, by the way.
Yeah, I have five minutes, right?
Oh.
Well, last slide at some point is here,
we will be giving training again of coccinality
at the lightness reference centre,
so super computing centre in Munich in Germany.
Yeah, and or at least one training.
And yeah, this work has been sponsored
by the Gauss Super Computing Centre,
and I was able to collaborate with Julia Lavald,
the Outro of Coccinality, also thanks to this travel grant.
We have two minutes for questions.
I think.
Thank you.