WEBVTT

00:00.000 --> 00:19.000
Hello, this is a very basic talk for people who know Coxinel, who knows Coxinel in this room,

00:19.000 --> 00:24.000
who uses Coxinel in this room.

00:24.000 --> 00:28.000
Can we do something about?

00:28.000 --> 00:32.000
All right, good.

00:32.000 --> 00:33.000
Nice.

00:33.000 --> 00:38.000
So Coxinel for those who, for the few who don't know,

00:38.000 --> 00:46.000
has, is a, is an engine for matching and matching c-code.

00:46.000 --> 00:51.000
And it's all, it has an own AST, as well, apart from the first place.

00:51.000 --> 00:54.000
An AST which is being built up on this.

00:54.000 --> 00:58.000
So it has a notion of c and to a good extent c++.

00:58.000 --> 01:02.000
And it allows first to match the entities of the c language

01:02.000 --> 01:04.000
and then to enact changes.

01:04.000 --> 01:11.000
So what is being called semantic patching or patching on those entities?

01:11.000 --> 01:16.000
And it matches also matches and patches control flow as well.

01:16.000 --> 01:17.000
So it's pretty powerful.

01:17.000 --> 01:23.000
And it's very easy, has a very easy notation to use.

01:23.000 --> 01:32.000
Yes, Coxinel originated around 20 years ago as a research to support.

01:32.000 --> 01:42.000
The research to support the Linux kernel to besides bugs,

01:42.000 --> 01:47.000
which are being originating from bad coding patterns.

01:47.000 --> 01:52.000
It's a, when there are situations which you can spot more or less with a pattern,

01:52.000 --> 01:54.000
some pattern in the code.

01:54.000 --> 02:01.000
Coxinel is there coxinel, so a led bug is there for you.

02:01.000 --> 02:08.000
In the kernel nowadays there are, I think, around 70 or so resident coxinel patches,

02:08.000 --> 02:14.000
which run with, when you trigger, make coxie check.

02:14.000 --> 02:23.000
So these are like static checks, static, static analyzer functionality of coxinel.

02:23.000 --> 02:28.000
So it's not much of, let's say you also can get hints on how to code the,

02:28.000 --> 02:32.000
change the, your code accordingly.

02:32.000 --> 02:43.000
But many more patches are being used by module containers in order to update drivers or custom modules,

02:43.000 --> 02:49.000
once new versions of Linux comes out.

02:50.000 --> 02:57.000
I work in HPC, I perform as computing, I don't work on the kernel.

02:57.000 --> 03:03.000
My interest is usually in helping scientists getting their code faster,

03:03.000 --> 03:09.000
either by helping them giving a technique or a library or maybe doing it myself.

03:09.000 --> 03:15.000
And the code patterns which are of my interest are around the APIs,

03:15.000 --> 03:19.000
so the programming interfaces of libraries,

03:19.000 --> 03:25.000
or notations which are called OpenMP or OpenECC or some others.

03:25.000 --> 03:33.000
Focus is to support the parting of old codes to GPUs, to GPUs,

03:33.000 --> 03:38.000
because it's not trivial for codes which are large exist in many years.

03:38.000 --> 03:43.000
And then maybe don't have funding for providing them for scratch.

03:43.000 --> 03:47.000
So parting can be useful, I could be, I mean,

03:47.000 --> 03:50.000
we wish to be available solution for some of those.

03:50.000 --> 03:54.000
And I'm also interested in to C++ related,

03:54.000 --> 03:57.000
refactoring on changes with coxinel,

03:57.000 --> 04:00.000
which were not in the first focus of coxinel,

04:00.000 --> 04:04.000
as it was being conceived for C.

04:04.000 --> 04:10.000
I think in an age of pollution in the physical sense,

04:10.000 --> 04:12.000
yeah, many other senses,

04:12.000 --> 04:17.000
were sublots and craft of all sorts present in the code,

04:17.000 --> 04:21.000
can be worst being removed, clean up somehow,

04:21.000 --> 04:24.000
at least detected, maybe with coxinel.

04:24.000 --> 04:26.000
These are things which are of my interest,

04:26.000 --> 04:29.000
which are a bit different if you see from what is of interest

04:29.000 --> 04:34.000
to the main probability to the kernel community.

04:34.000 --> 04:37.000
And you know, interest is also to speak about this,

04:37.000 --> 04:42.000
to diffuse this knowledge in the HPC community

04:42.000 --> 04:44.000
and if there is something good for coxinel,

04:44.000 --> 04:47.000
also in the kernel community.

04:47.000 --> 04:50.000
Who knows compiler explorer,

04:50.000 --> 04:54.000
half of the room knows compiler explorer,

04:54.000 --> 04:57.000
we use compiler explorer to view snippets

04:57.000 --> 05:00.000
or to write snippets of code,

05:00.000 --> 05:03.000
of compiler code and to get

05:04.000 --> 05:07.000
assembly codes in output,

05:07.000 --> 05:10.000
without having to have those different compilers,

05:10.000 --> 05:13.000
which we can select here on our computer,

05:13.000 --> 05:15.000
or those different machines,

05:15.000 --> 05:18.000
which are platform of target set list,

05:18.000 --> 05:19.000
supported,

05:19.000 --> 05:22.000
and we can do this on many programming languages,

05:22.000 --> 05:24.000
which we can select here.

05:24.000 --> 05:27.000
So this is a website just for the ones who don't know it,

05:27.000 --> 05:30.000
gotbought.org is the website,

05:31.000 --> 05:34.000
and it's a useful tool for

05:34.000 --> 05:37.000
programming, for checking programming,

05:37.000 --> 05:39.000
programs, nips,

05:39.000 --> 05:42.000
different, yeah, with different compilers,

05:42.000 --> 05:45.000
different languages, yeah.

05:45.000 --> 05:47.000
Good.

05:47.000 --> 05:52.000
So compiler explorer has been written in a typescript

05:52.000 --> 05:54.000
by Matt Rodbought.

05:54.000 --> 05:59.000
It's a useful learning tool for training,

05:59.000 --> 06:01.000
for doing trainings in C++, for instance,

06:01.000 --> 06:03.000
for showing nips to other people,

06:03.000 --> 06:04.000
like, hey, I did this,

06:04.000 --> 06:06.000
and you can share,

06:06.000 --> 06:08.000
as nips that you did,

06:08.000 --> 06:10.000
you can show bugs to other people

06:10.000 --> 06:14.000
that you found in the compilation of programs,

06:14.000 --> 06:18.000
and it's also open to new compilers,

06:18.000 --> 06:19.000
and new languages,

06:19.000 --> 06:21.000
so the authors of compilers

06:21.000 --> 06:24.000
experts accept contributions,

06:24.000 --> 06:27.000
so that maybe we can contribute,

06:27.000 --> 06:31.000
we can give access to coccinality here as well, somehow.

06:31.000 --> 06:34.000
So, not an actual type script,

06:34.000 --> 06:38.000
but still I tried a bit, playing with it,

06:38.000 --> 06:41.000
and I came up with something like this.

06:41.000 --> 06:44.000
So since as far as,

06:44.000 --> 06:45.000
well,

06:45.000 --> 06:48.000
in the first order of approximation,

06:48.000 --> 06:52.000
without creating a separate window here,

06:52.000 --> 06:54.000
because coccinality as we will see now,

06:54.000 --> 06:57.000
works by having at least two inputs.

06:57.000 --> 07:00.000
So a program which will write in the coccinality language,

07:00.000 --> 07:02.000
the semantic patch language,

07:02.000 --> 07:06.000
in an arbitrary amount of C++ code,

07:06.000 --> 07:11.000
the code which we should match and batch.

07:11.000 --> 07:17.000
So you would need at least two sections here.

07:17.000 --> 07:19.000
I was in a hurry,

07:19.000 --> 07:22.000
I just wanted to create a prototype,

07:22.000 --> 07:25.000
just for checking the idea and sharing it with people.

07:25.000 --> 07:29.000
So I resorted to the trick of having some EFTF here,

07:29.000 --> 07:33.000
in a way that you could compile this whole thing here,

07:33.000 --> 07:38.000
so you would write your C program up here,

07:38.000 --> 07:41.000
you would write your coccinality rule,

07:41.000 --> 07:44.000
because coccinality programs are code rules,

07:44.000 --> 07:46.000
down here separated by this EFTF,

07:46.000 --> 07:48.000
so this is the notation in order to separate it.

07:48.000 --> 07:50.000
It's pretty primitive if you want,

07:50.000 --> 07:52.000
but it does the job.

07:52.000 --> 07:54.000
Okay, let's see,

07:54.000 --> 07:57.000
for who doesn't know coccinality,

07:57.000 --> 08:01.000
let this be a good moment to get a idea of it.

08:01.000 --> 08:03.000
So here in this coccinality rule,

08:03.000 --> 08:07.000
we remove a lot of occurrences of the literal zero,

08:07.000 --> 08:10.000
and we wish to replace them with the literal one.

08:10.000 --> 08:13.000
And the program here, which has just one occurrence

08:13.000 --> 08:16.000
of the zero literal,

08:16.000 --> 08:19.000
becomes gets patched to this.

08:19.000 --> 08:20.000
What is the patch?

08:20.000 --> 08:25.000
The patch is somewhere here in this hover at window.

08:25.000 --> 08:28.000
Yeah, and this is the patched file.

08:28.000 --> 08:33.000
Which is the new functionality with respect to coccinality.

08:33.000 --> 08:35.000
Well, just that you can do this in a browser,

08:35.000 --> 08:38.000
because we do like doing things in the browser in the last years,

08:38.000 --> 08:41.000
and that more or less interactively,

08:41.000 --> 08:44.000
as you finish typing here, you get the output here,

08:44.000 --> 08:47.000
and therefore it's a learning tool.

08:48.000 --> 08:54.000
Because it accelerates the loop of getting back the result of your actions.

08:54.000 --> 08:55.000
Yeah, same story.

08:55.000 --> 09:00.000
If you use the coccinality notation to match the constants,

09:00.000 --> 09:03.000
so you create the meta variable constant C,

09:03.000 --> 09:09.000
which is get instance that each time a constant is being

09:09.000 --> 09:12.000
and counter it, and you want to wish to replace it,

09:12.000 --> 09:17.000
so a plus line with the literal chart C,

09:17.000 --> 09:20.000
zero becomes chart C here.

09:20.000 --> 09:24.000
So this is just to give you the complete basics of coccinality.

09:24.000 --> 09:29.000
Further, we have rules where you can modify symbols.

09:29.000 --> 09:35.000
In this way here, we say that those symbols should be treated as identifiers,

09:35.000 --> 09:38.000
and therefore all occurrences of A here

09:39.000 --> 09:42.000
get replaced with bidder.

09:42.000 --> 09:46.000
Further expressions can be matched,

09:46.000 --> 09:50.000
so arbitrarily complicated expressions can be matched,

09:50.000 --> 09:52.000
and replaced with context.

09:52.000 --> 09:57.000
Here we are putting a minus and a plus in the middle of a set of a statement,

09:57.000 --> 10:02.000
because coccinality is quite agnostic to a white space.

10:02.000 --> 10:06.000
So this language here tolerates white space,

10:06.000 --> 10:12.000
as long as you do a good job in putting the semi-colons where they belong.

10:12.000 --> 10:18.000
What happens when you write something wrong,

10:18.000 --> 10:21.000
like in the coccinality terms,

10:21.000 --> 10:24.000
like this rule here, which is wrong,

10:24.000 --> 10:26.000
you have to click at the moment you have to click here,

10:26.000 --> 10:32.000
or simply look that the outcalls has six lines of a standard error.

10:32.000 --> 10:35.000
This standard error is complete.

10:35.000 --> 10:38.000
It's saying partial error in the coccinality rule.

10:38.000 --> 10:41.000
Yeah, so this is the minimum to get some,

10:41.000 --> 10:44.000
to understand something, what did you do wrong?

10:44.000 --> 10:50.000
Yeah, this is the good way to do the patching from before,

10:50.000 --> 10:52.000
from before.

10:52.000 --> 10:56.000
The C++, as I said, we are working gradually,

10:56.000 --> 11:00.000
so my focus is also in introducing C++,

11:01.000 --> 11:03.000
from reporting the C++ changes,

11:03.000 --> 11:06.000
who uses C++ to certain extent?

11:06.000 --> 11:08.000
Ah, quite a lot of people, good.

11:08.000 --> 11:10.000
So this is like one feature of C++ 23,

11:10.000 --> 11:16.000
so multi-index bracket statements, or, sorry, accesses,

11:16.000 --> 11:17.000
would.

11:17.000 --> 11:20.000
Compiler explorer and by extension,

11:20.000 --> 11:23.000
let's call it coccinality explorer,

11:23.000 --> 11:26.000
can offer you a catalog of examples,

11:26.000 --> 11:28.000
where not yet there.

11:28.000 --> 11:31.000
And can load and save files to your system,

11:31.000 --> 11:33.000
and if this gets into, yeah,

11:33.000 --> 11:35.000
if this gets accepted,

11:35.000 --> 11:37.000
this prototype into Compiler explorer,

11:37.000 --> 11:40.000
we might have here like useful examples to learn

11:40.000 --> 11:42.000
and practice coccinality,

11:42.000 --> 11:46.000
perhaps we will get the window nicely split,

11:46.000 --> 11:47.000
so we will see.

11:47.000 --> 11:51.000
I think you can try already this.

11:51.000 --> 11:54.000
There is a poor request here, being reviewed.

11:55.000 --> 11:59.000
All it took to me was to install not JS version 20

11:59.000 --> 12:02.000
and run this locally on my laptop,

12:02.000 --> 12:05.000
and I could have this in the browser running,

12:05.000 --> 12:07.000
and this was enough for me,

12:07.000 --> 12:10.000
and some people which learned coccinality

12:10.000 --> 12:12.000
were very happy of getting this.

12:12.000 --> 12:17.000
So this is a proof of concept so far.

12:17.000 --> 12:20.000
I wanted to probe with people like this,

12:20.000 --> 12:22.000
primarily when teaching coccinality,

12:22.000 --> 12:27.000
and very happy, yeah, of knowing from your what you think.

12:27.000 --> 12:31.000
We have this ugly preprocessor trick at the moment

12:31.000 --> 12:34.000
to separate the rule from the C program.

12:34.000 --> 12:37.000
Maybe one day we will get a window in between,

12:37.000 --> 12:39.000
windows splitting between.

12:39.000 --> 12:43.000
I don't know if this can be easily supported by the backbone

12:43.000 --> 12:46.000
of the code of Compiler Explorer,

12:46.000 --> 12:51.000
also having like the tactical material here specific for this.

12:51.000 --> 12:52.000
We don't have yet.

12:52.000 --> 12:57.000
And we also don't have specific options

12:57.000 --> 13:00.000
of the many options with coccinality.

13:00.000 --> 13:04.000
I'm happy of getting feedback to tell me,

13:04.000 --> 13:07.000
to tell us what could be useful here.

13:07.000 --> 13:09.000
And so yeah.

13:09.000 --> 13:12.000
So in order to use coccinality properly,

13:12.000 --> 13:14.000
there is a coccinality training,

13:14.000 --> 13:16.000
which I gave like one week ago,

13:16.000 --> 13:19.000
with new material or the fresh material.

13:19.000 --> 13:22.000
You get it here.

13:22.000 --> 13:26.000
Yeah, this lights are already uploaded.

13:26.000 --> 13:28.000
And this is very new.

13:28.000 --> 13:32.000
I think the first ever coccinality cheat sheet.

13:32.000 --> 13:35.000
So you will not learn coccinality from this,

13:35.000 --> 13:37.000
but if you already know coccinality a bit,

13:37.000 --> 13:39.000
I think this summarizes the important things

13:39.000 --> 13:41.000
when you need them.

13:41.000 --> 13:44.000
So I really recommend giving it a look,

13:44.000 --> 13:48.000
and of course giving me feedback for improving it.

13:48.000 --> 13:50.000
Yeah, at some point probably we will push it

13:50.000 --> 13:55.000
into the coccinality augmentation, by the way.

13:55.000 --> 13:58.000
Yeah, I have five minutes, right?

13:58.000 --> 14:00.000
Oh.

14:00.000 --> 14:03.000
Well, last slide at some point is here,

14:03.000 --> 14:09.000
we will be giving training again of coccinality

14:09.000 --> 14:11.000
at the lightness reference centre,

14:11.000 --> 14:16.000
so super computing centre in Munich in Germany.

14:16.000 --> 14:20.000
Yeah, and or at least one training.

14:20.000 --> 14:23.000
And yeah, this work has been sponsored

14:23.000 --> 14:26.000
by the Gauss Super Computing Centre,

14:26.000 --> 14:30.000
and I was able to collaborate with Julia Lavald,

14:30.000 --> 14:34.000
the Outro of Coccinality, also thanks to this travel grant.

14:34.000 --> 14:38.000
We have two minutes for questions.

14:38.000 --> 14:39.000
I think.

14:39.000 --> 14:44.000
Thank you.

