Skip to content

Add OpenMP kernels#389

Merged
vgvassilev merged 1 commit intocompiler-research:mainfrom
mcbarton:Add-OpenMP-kernel
Mar 30, 2026
Merged

Add OpenMP kernels#389
vgvassilev merged 1 commit intocompiler-research:mainfrom
mcbarton:Add-OpenMP-kernel

Conversation

@mcbarton
Copy link
Copy Markdown
Collaborator

@mcbarton mcbarton commented Oct 7, 2025

Description

Please include a summary of changes, motivation and context for this PR.

Fixes # (issue)

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Added/removed dependencies
  • Required documentation updates

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (4d2e571) to head (1dccd67).

Files with missing lines Patch % Lines
src/xinterpreter.cpp 92.30% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #389      +/-   ##
==========================================
+ Coverage   80.28%   80.56%   +0.27%     
==========================================
  Files          21       21              
  Lines         847      854       +7     
  Branches       78       80       +2     
==========================================
+ Hits          680      688       +8     
+ Misses        167      166       -1     
Files with missing lines Coverage Δ
src/xinterpreter.cpp 89.24% <92.30%> (+1.16%) ⬆️
Files with missing lines Coverage Δ
src/xinterpreter.cpp 89.24% <92.30%> (+1.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch 3 times, most recently from e4af2d6 to 3824a2f Compare October 9, 2025 07:23
@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Oct 9, 2025

Things done so far

  • Add c++ + openmp kernels (includes kernel definition json files added, and cmake change)
  • Updated documentation so that LD_LIBRARY_PATH is defined
  • Add example c++ + openmp notebooks which have been tested locally to work (taken from xeus-clang-repl)

List of things still to do

  • Add c + openmp kernels
  • Update ci so LD_LIBRARY_PATH is defined and openmp kernels can be tested
  • Add some tests for the openmp kernels

@vgvassilev
Copy link
Copy Markdown
Contributor

We should probably have a openmp specific ci without having to rely on the ld_library_path..

@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Oct 9, 2025

We should probably have a openmp specific ci without having to rely on the ld_library_path..

@vgvassilev Having an openmp specific ci will not avoid the need for ld_library_path. To avoid ld_library_path you would need to rework the cmake and the kernelspec (which makes reference to this variable) , and the example notebooks would need to know the path where you stored the openmp library. Using ld_library_path like xeus-clang-repl did simplifies this PR.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch 3 times, most recently from 45a4ee5 to 571023c Compare October 9, 2025 12:43
@vgvassilev
Copy link
Copy Markdown
Contributor

We should probably have a openmp specific ci without having to rely on the ld_library_path..

@vgvassilev Having an openmp specific ci will not avoid the need for ld_library_path. To avoid ld_library_path you would need to rework the cmake and the kernelspec (which makes reference to this variable) , and the example notebooks would need to know the path where you stored the openmp library. Using ld_library_path like xeus-clang-repl did simplifies this PR.

Okay, let's see if that's compatible with the vision of @SylvainCorlay which he expressed recently.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch 2 times, most recently from 5d1ad18 to 5a2630d Compare October 10, 2025 07:47
@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Oct 10, 2025

@vgvassilev @alexander-penev @Vipul-Cariappa @anutosh491 @SylvainCorlay I now consider this PR ready for review. It adds c and c++ kernels that have openmp. It includes example notebooks for the c++ + openmp kernels taken from xeus-clang-repl which were able to run when I tried locally. It also has one simple openmp test for the jupyter kernel test tests. I wasn't exactly sure what would suffice as an automatic test, but the test clearly demonstrates the kernel is executing OpenMP code.

Copy link
Copy Markdown
Collaborator

@Vipul-Cariappa Vipul-Cariappa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to these changes; The user after selecting a omp kernel, still needs to include CppInterOp.h and call Cpp::LoadLibrary(...). The user should not be expected to know the internals and do this.
When we launch a kernel that enables OpenMP, it should automatically load all necessary stuff. You need to parse the compiler arguments, check if it contains -fopenmp, if yes, call LoadLibrary.
Also, can you share the contents of kernel.json files that gets installed.

Stretch goal (may not be possible): Can we get it to work, without modifying the LD_LIBRARY_PATH env var?

@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Oct 14, 2025

I think I have an idea of how to avoiding needing ld library path. My new method should work on the Windows once we have that platform working too. I just need to test it out, and plan to test it out sometime in the next few days.

I'm not so convinced that making the user have to include CppInterOp.h, and calling cpp::LoadLibrary(...) is as big deal as you make out to be. It would also let the user know to use other (non openmp) shared libraries in their notebooks. The example notebooks are there for a reason. I kept this PR the way xeus-clang-repl did openmp kernels. Despite this I will look into working out to have the kernel automatically do this if it notices -fopenmp in the kernel arguments.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch 3 times, most recently from 2dac7b4 to a41ed55 Compare October 15, 2025 12:34
@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch 7 times, most recently from f1f66c3 to ee5c14d Compare March 27, 2026 09:03
@vgvassilev
Copy link
Copy Markdown
Contributor

@mcbarton, can you squash all into a single commit?

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch from ee5c14d to d023252 Compare March 27, 2026 10:11
@mcbarton
Copy link
Copy Markdown
Collaborator Author

@mcbarton, can you squash all into a single commit?

@vgvassilev I have squashed all commits into a single commit

@vgvassilev
Copy link
Copy Markdown
Contributor

Quick question : Can we just start with 1 OMP kernel instead of starting with 6 ?

Why maintain 6 when we are planning to refactor into 1 paramterized kernel spec !

Looks like a permutation and combination of language * versions * omp to me.

Even if there's time before the parameterized kernel spec lands, I think its just too much to maintain :\

So if we land a cuda kernel as was being discussed recently on discord, we again land 6 more kernel ?

Can we add one kernel per language’s highest supported standard version then?

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch from d023252 to 52887d2 Compare March 27, 2026 13:25
@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Mar 27, 2026

Quick question : Can we just start with 1 OMP kernel instead of starting with 6 ?
Why maintain 6 when we are planning to refactor into 1 paramterized kernel spec !
Looks like a permutation and combination of language * versions * omp to me.
Even if there's time before the parameterized kernel spec lands, I think its just too much to maintain :
So if we land a cuda kernel as was being discussed recently on discord, we again land 6 more kernel ?

Can we add one kernel per language’s highest supported standard version then?

@vgvassilev Done. There is now just a single openmp kernel for each language. A c++23 + openmp kernel, and a c23 + openmp kernel.

@anutosh491
Copy link
Copy Markdown
Collaborator

Can we add one kernel per language’s highest supported standard version then?

Hopefully that makes sense !?

Some standard C/C++ kernels + 1 kernel per speciliazed case sounds just good enough to maintain right ?

@vgvassilev
Copy link
Copy Markdown
Contributor

Can we add one kernel per language’s highest supported standard version then?

Hopefully that makes sense !?

Some standard C/C++ kernels + 1 kernel per speciliazed case sounds just good enough to maintain right ?

To be honest there is no maintenance cost for these things so far but let's start with what you suggest.

@mcbarton
Copy link
Copy Markdown
Collaborator Author

Can we add one kernel per language’s highest supported standard version then?

Hopefully that makes sense !?
Some standard C/C++ kernels + 1 kernel per speciliazed case sounds just good enough to maintain right ?

To be honest there is no maintenance cost for these things so far but let's start with what you suggest.

I think I have implemented what has been suggested with only 1 c and 1 c++ openmp kernel. I may need further explaination if I have not.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch from 52887d2 to ea013db Compare March 29, 2026 16:42
Copy link
Copy Markdown
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like getting very close to a merge. Can we have only one hello world notebook in tree and the rest to move to https://github.com/compiler-research/live-cpp-tutorials

We will need to figure out how to run these as part of the ci.

@mcbarton
Copy link
Copy Markdown
Collaborator Author

This looks like getting very close to a merge. Can we have only one hello world notebook in tree and the rest to move to https://github.com/compiler-research/live-cpp-tutorials

We will need to figure out how to run these as part of the ci.

I will move these notebooks during my lunch break.

I already know how to run the notebooks as part of the ci. This PR we talked about the other day on Discord runs the notebooks for Jupyter Lite as part of the ci #415 . Once that is in, I will work on modifying the script so it can run notebooks for the native case too.

@mcbarton mcbarton force-pushed the Add-OpenMP-kernel branch from ea013db to a92c9a2 Compare March 30, 2026 09:13
@mcbarton
Copy link
Copy Markdown
Collaborator Author

mcbarton commented Mar 30, 2026

I've now reduced to just the hello world notebook, and opened up the PR moving the other notebooks here compiler-research/live-cpp-tutorials#1

@vgvassilev vgvassilev merged commit 5e4a82b into compiler-research:main Mar 30, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants