Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds -fopenmp flag to omp kernels + adds c++20 omp kernel #100

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
run: |
mkdir -p build
cd build
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"
echo $LD_LIBRARY_PATH
find "$CONDA_PREFIX/include"
cmake .. \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
Expand Down
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ endif()

find_package(argparse REQUIRED)
find_package(pugixml REQUIRED)

find_package(OpenMP)
# Configuration
# =============

Expand All @@ -135,8 +135,15 @@ function(configure_kernel kernel)
set(XEUS_CPP_PATH "$ENV{PATH}")
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/)

if(${kernel} MATCHES "omp/$")
set(XEUS_CPP_OMP "${OpenMP_CXX_FLAGS}")
endif()

message(Configure_Kernel "${kernel}")
message(CPP_OMP_FLAG "${XEUS_CPP_OMP}")
message(CPP_INCLUDE_DIR "${XEUS_CPP_INCLUDE_DIR}")
if (WIN32)
string(REPLACE "\\" "/" kernel "${kernel}")
string(REPLACE "\\" "/" XEUS_CPP_PATH "${XEUS_CPP_PATH}")
Expand Down Expand Up @@ -167,7 +174,9 @@ message("Configure kernels: ...")
configure_kernel("/share/jupyter/kernels/xcpp11/")
configure_kernel("/share/jupyter/kernels/xcpp14/")
configure_kernel("/share/jupyter/kernels/xcpp17/")
configure_kernel("/share/jupyter/kernels/xcpp17-omp/")
configure_kernel("/share/jupyter/kernels/xcpp20/")
configure_kernel("/share/jupyter/kernels/xcpp20-omp/")

# Source files
# ============
Expand Down
3 changes: 2 additions & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ dependencies:
- jupyter_kernel_test>=0.4.3
- nbval
- pytest-rerunfailures
- doctest
- doctest
- llvm-openmp
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp11/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++11"@XEUS_CPP_OMP@
"-std=c++11","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false}
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp14/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"-std=c++14",
"-fno-exceptions",
"-O2",
"-v"@XEUS_CPP_OMP@
"-v","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false}
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17-omp/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++17"@XEUS_CPP_OMP@
"-std=c++17","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp17/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++17"@XEUS_CPP_OMP@
"-std=c++17","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false
Expand Down
19 changes: 19 additions & 0 deletions share/jupyter/kernels/xcpp20-omp/kernel.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"display_name": "C++20 (xcpp+OpenMP)",
"env": {
"PATH":"@XEUS_CPP_PATH@",
"LD_LIBRARY_PATH":"@XEUS_CPP_LD_LIBRARY_PATH@",
"CPLUS_INCLUDE_PATH":"@CMAKE_CPLUS_INCLUDE_PATH@"
},
"argv": [
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-f",
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++20","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false
}
}
Binary file added share/jupyter/kernels/xcpp20-omp/logo-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added share/jupyter/kernels/xcpp20-omp/logo-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions share/jupyter/kernels/xcpp20-omp/logo-svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xcpp20/kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"{connection_file}",
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
"-I", "@XEUS_CPP_INCLUDE_DIR@",
"-std=c++20"@XEUS_CPP_OMP@
"-std=c++20","@XEUS_CPP_OMP@"
],
"language": "cpp",
"metadata": {"debugger": false
Expand Down
15 changes: 13 additions & 2 deletions test/test_xcpp_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_continuation(self) -> None:
if platform.system() != 'Windows':
class XCppTests(jupyter_kernel_test.KernelTests):

kernel_name = 'xcpp20'
kernel_name = 'xcpp20-omp'

# language_info.name in a kernel_info_reply should match this
language_name = 'C++'
Expand Down Expand Up @@ -131,6 +131,17 @@ class XCppTests(jupyter_kernel_test.KernelTests):
'mime': 'image/png'
}
]
code_omp="""
#include <omp.h>
#include <iostream>
#include <clang/Interpreter/CppInterOp.h>
"""
def test_xcpp_omp(self):
self.flush_channels()
reply, output_msgs = self.execute_helper(code=self.code_omp,timeout=20)
self.assertEqual(output_msgs[0]['msg_type'], 'stream')
self.assertEqual(output_msgs[0]['content']['name'], 'stderr')
self.assertEqual(output_msgs[0]['content']['text'], '2')


class XCppTests2(jupyter_kernel_test.KernelTests):
Expand All @@ -145,4 +156,4 @@ class XCppTests2(jupyter_kernel_test.KernelTests):


if __name__ == '__main__':
unittest.main()
unittest.main()
Loading