Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c23c9dc
Find plugins correctly on linux.
bredelings Feb 5, 2024
4cbae0b
Export compile commands.
bredelings Feb 7, 2024
3ffb5d5
Only set CMAKE_BUILD_TYPE if not already set.
bredelings Feb 7, 2024
2313fc5
Don't add optimization flags in debug mode.
bredelings Feb 7, 2024
17bd367
Remove unneeded manual -stdc=c++11 argument.
bredelings Feb 7, 2024
b711336
Use colons instead of semicolongs in RPATH
bredelings Feb 12, 2024
0861f83
Initial build file.
bredelings Feb 12, 2024
6147719
Compilation fix: cast to void*
bredelings Feb 12, 2024
286e7e9
Handle compiling for windows with mingw32-gcc
bredelings Feb 12, 2024
e4ad236
Ensure destructor is virtual.
bredelings Feb 12, 2024
eb9a74f
Remove exception specifications.
bredelings Feb 12, 2024
497167f
Test _WIN32 not WIN32
bredelings Feb 12, 2024
e3fbb47
Choose flag format based on compiler, not OS.
bredelings Feb 13, 2024
b750ba8
Also install opencl on Linux.
bredelings Feb 13, 2024
907753f
Remove debugoptimized version wich doesn't change anthing.
bredelings Feb 13, 2024
d6d7bed
Try manually adding ccache to toolchain file
bredelings Feb 13, 2024
7009271
Fix optimization flags.
bredelings Feb 14, 2024
0aeb50a
Define HAVE_CPUID_H if we have <cpuid.h>
bredelings Feb 26, 2024
e479743
Run an apt-get update.
bredelings Feb 26, 2024
2d4ba88
Try to fix builds by disabling opencl.
bredelings Jun 3, 2024
69b7b38
Just say OpenMP is off.
bredelings Jun 5, 2024
9e9de7d
Just don't install opencl
bredelings Jun 5, 2024
d05c39b
Just request python 3.12, not 3.12.0
bredelings Jun 12, 2024
36b67f3
Try switching to xcode 16
bredelings Dec 9, 2024
39edee7
Try switching windows build to ubuntu 24.04
bredelings Dec 9, 2024
7db4f74
Switch mac into build to MacOs-13
bredelings Dec 9, 2024
9158aca
Use XCode 15 for MacOs 13
bredelings Dec 9, 2024
29e9dc3
Don't run find_package(CUDA) if BUILD_CUDA=OFF
bredelings Mar 4, 2025
4b405e3
Remove ubuntu-20.04, as it is too old.
bredelings May 7, 2025
2a35994
Update ccache bit.
bredelings May 7, 2025
6dd7c4a
Add missing matrix name.
bredelings May 7, 2025
1b62c44
Update test script
bredelings Aug 19, 2025
cc73d15
Don't try and run ./actiontest on this branch
bredelings Aug 19, 2025
ade7e58
Only set JNI sources if BUILD_JNI is ON.
bredelings Feb 13, 2024
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
191 changes: 191 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build and test

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
build:
strategy:
matrix:
name: [ubuntu-gcc-12,
ubuntu-gcc-13,
ubuntu-gcc-14,
ubuntu-gcc-15,
ubuntu-gcc-15-debug,
ubuntu-clang-17,
ubuntu-clang-19,
macos-xcode-15-intel,
macos-xcode-16-arm,
windows
]

include:

- name: ubuntu-gcc-12
os: ubuntu-22.04
compiler: gcc
version: "12"
arch: "linux64"

- name: ubuntu-gcc-13
os: ubuntu-24.04
compiler: gcc
version: "12"
arch: "linux64"

- name: ubuntu-gcc-14
os: ubuntu-24.04
compiler: gcc
version: "12"
arch: "linux64"

- name: ubuntu-gcc-15
os: ubuntu-24.04
compiler: gcc
version: "12"
buildtype: "Release"
arch: "linux64"
image: ubuntu:25.04

- name: ubuntu-gcc-15-debug
os: ubuntu-24.04
compiler: gcc
version: "12"
buildtype: "Debug"
arch: "linux64"
image: ubuntu:25.04

- name: ubuntu-clang-17
os: ubuntu-24.04
compiler: clang
version: "17"
buildtype: "Release"
arch: "linux64"

- name: ubuntu-clang-19
os: ubuntu-24.04
compiler: clang
version: "19"
buildtype: "Release"
arch: "linux64"

- name: macos-xcode-15-intel
os: macos-13
compiler: xcode
version: "15"
arch: "mac-intel64"

- name: macos-xcode-16-arm
os: macos-14
compiler: xcode
version: "16"
arch: "mac-arm64"

- name: windows
os: ubuntu-24.04
compiler: mingw
version: "N/A"
arch: "win64"

runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.image || '' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12

# Caches for different branches are isolated, so we don't need to put the branch name into the key.
# The total size for all caches in a repository is 5Gb.

- name: Set CMake build type
run: |
CMAKE_ARGS=""
if [ -n "${{ matrix.buildtype }}" ] ; then
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }}"
fi
echo "CMAKE_ARGS=${CMAKE_ARGS}" >> $GITHUB_ENV

- name: Install utilities (Linux)
if: runner.os == 'Linux' && matrix.name != 'windows'
run: |
# If we're running in a docker image, we are already root
if [ -n "${{ matrix.image }}" ] ; then
apt-get update && apt-get install -y sudo build-essential git cmake
fi

sudo apt-get update
sudo apt-get install -y cmake ninja-build ccache pkg-config
sudo apt-get install -y openjdk-17-jdk libeigen3-dev

if [ "${{ matrix.compiler }}" = "gcc" ]; then
# For newer GCCs, maybe.
# sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
# sudo apt-get update

sudo apt-get install -y g++-${{ matrix.version }}
echo "CC=ccache gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=ccache g++-${{ matrix.version }}" >> $GITHUB_ENV
else
sudo apt-get install -y clang-${{ matrix.version }}
echo "CC=ccache clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=ccache clang++-${{ matrix.version }}" >> $GITHUB_ENV
echo "CMAKE_ARGS=${CMAKE_ARGS} -DBUILD_OPENMP=OFF" >> $GITHUB_ENV
fi

- name: Install utilities (Linux -> Windows [cross])
if: matrix.name == 'windows'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build ccache pkg-config
sudo apt-get install -y dos2unix g++-mingw-w64 mingw-w64-tools wine64 zstd

echo "CMAKE_ARGS=${CMAKE_ARGS} -DBUILD_JNI=OFF -DBUILD_OPENMP=OFF -DCMAKE_TOOLCHAIN_FILE=scripts/mingw-w64-x86_64.cmake" >> $GITHUB_ENV

- name: Select XCode version (macOS)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.version }}

- name: Install utilities (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake ninja pkg-config ccache coreutils eigen openjdk
echo "CC=ccache clang" >> $GITHUB_ENV
echo "CXX=ccache clang++" >> $GITHUB_ENV
echo "CMAKE_ARGS=${CMAKE_ARGS} -DBUILD_OPENMP=OFF" >> $GITHUB_ENV

- name: Set up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.name }}
restore-keys: |
${{ matrix.name }}

- name: Configure
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/local ${CMAKE_ARGS}

- name: Build
run: |
ccache -p
ccache -s
ninja -C build install -j4
ccache -s

- name: Test
if: matrix.name != 'windows'
run: |
cd build
./examples/synthetictest
./examples/hmctest

42 changes: 33 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,32 @@ add_definitions(
)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#SET(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

## flags for standard library
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox /Ot /MT")
else(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -pthread")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -pthread")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
endif(WIN32)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif ()


if (NOT "${CMAKE_BUILD_TYPE}" MATCHES Debug)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox /Ot")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
endif()
endif()

#if(NOT WIN32)
# add_definitions(-DHAVE_CONFIG_H)
Expand Down Expand Up @@ -155,6 +166,12 @@ if(APPLE)

# Seems necessary from macOS 10.15
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
elseif(UNIX)
# This tells libhmsbeagle.so to search the same directory to find plugins.
SET(CMAKE_INSTALL_RPATH "\$ORIGIN")
# $ORIGIN/{CPU,GPU,JNI} is so that libhmsbeagle.so can find the plugins in their build location.
# $ORIGIN/../libhmsbeagle is so that examples/* can find libhmsbeagle.so
SET(CMAKE_BUILD_RPATH "\$ORIGIN:\$ORIGIN/CPU:\$ORIGIN/GPU:\$ORIGIN/JNI:\$ORIGIN/../libhmsbeagle")
endif(APPLE)

if (BEAGLE_OPTIMIZE_FOR_NATIVE_ARCH)
Expand All @@ -170,6 +187,13 @@ if (BEAGLE_OPTIMIZE_FOR_NATIVE_ARCH)
endif()
endif()


include(CheckIncludeFileCXX)
check_include_file_cxx("cpuid.h" HAVE_CPUID_H)
if (HAVE_CPUID_H)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_CPUID_H")
endif()

add_subdirectory(libhmsbeagle)

link_libraries(hmsbeagle)
Expand Down
11 changes: 6 additions & 5 deletions libhmsbeagle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
if(WIN32)
add_definitions(-D_EXPORTING)
add_definitions(-DWIN32)
add_definitions(-D_CONSOLE)
# add_definitions(-DPACKAGE_VERSION="${BEAGLE_VERSION}")
# add_definitions(-DPLUGIN_VERSION="${BEAGLE_PLUGIN_VERSION}")
Expand All @@ -14,10 +13,12 @@ if(WIN32)
plugin/WinSharedLibrary.h
)

set(BEAGLE_INTEGRATED_JNI_SOURCE
JNI/beagle_BeagleJNIWrapper.cpp
JNI/beagle_BeagleJNIWrapper.h
)
if (BUILD_JNI)
set(BEAGLE_INTEGRATED_JNI_SOURCE
JNI/beagle_BeagleJNIWrapper.cpp
JNI/beagle_BeagleJNIWrapper.h
)
endif()
else(WIN32)
set(BEAGLE_PLUGIN_SUFFIX ".so")
set(BEAGLE_INSTALL_DIR lib)
Expand Down
2 changes: 1 addition & 1 deletion libhmsbeagle/CPU/BeagleCPUImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4826,7 +4826,7 @@ BEAGLE_CPU_TEMPLATE
void* BeagleCPUImpl<BEAGLE_CPU_GENERIC>::mallocAligned(size_t size) {
void *ptr = (void *) NULL;

#if defined (__APPLE__) || defined(WIN32)
#if defined (__APPLE__) || defined(_WIN32)
/*
presumably malloc on OS X always returns
a 16-byte aligned pointer
Expand Down
2 changes: 1 addition & 1 deletion libhmsbeagle/CPU/BeagleCPUSSEPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool check_sse2(){

#endif

#ifdef __GNUC__
#if defined(__GNUC__) && !defined(_WIN32)
#if !defined(DLS_MACOS) // For non-Mac OS X GNU C
bool check_sse2()
{
Expand Down
14 changes: 8 additions & 6 deletions libhmsbeagle/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

find_package(OpenCL)
if(BUILD_OPENCL)
find_package(OpenCL)
# set(OpenCL_INCLUDE_DIRS /opt/rocm/opencl/include)
# set(OpenCL_LIBRARIES /opt/rocm/opencl/lib/libOpenCL.so)
if(OpenCL_FOUND OR (OpenCL_INCLUDE_DIRS AND OpenCL_LIBRARIES))
Expand All @@ -10,9 +10,11 @@ if(BUILD_OPENCL)
endif(OpenCL_FOUND OR (OpenCL_INCLUDE_DIRS AND OpenCL_LIBRARIES))
endif(BUILD_OPENCL)

find_package(CUDA)
if(CUDA_FOUND AND BUILD_CUDA)
message(STATUS "CUDA Includes: ${CUDA_INCLUDE_DIRS}")
add_subdirectory("CMake_CUDA")
endif(CUDA_FOUND AND BUILD_CUDA)
if(BUILD_CUDA)
find_package(CUDA)
if(CUDA_FOUND)
message(STATUS "CUDA Includes: ${CUDA_INCLUDE_DIRS}")
add_subdirectory("CMake_CUDA")
endif(CUDA_FOUND)
endif(BUILD_CUDA)

3 changes: 3 additions & 0 deletions libhmsbeagle/plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BEAGLE_DLLEXPORT Plugin
Plugin(const char* plugin_name, const char* plugin_type)
: m_plugin_name(plugin_name), m_plugin_type(plugin_type) {}

// Make sure the destructor is virtual.
virtual ~Plugin() {}

virtual std::string pluginName() const{ return m_plugin_name; }
virtual std::string pluginType() const{ return m_plugin_type; }

Expand Down
1 change: 0 additions & 1 deletion libhmsbeagle/plugin/WinSharedLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace beagle {
namespace plugin {

SharedLibrary* SharedLibrary::openSharedLibrary(const char* name)
throw (SharedLibraryException)
{
return new WinSharedLibrary(name);
}
Expand Down
10 changes: 3 additions & 7 deletions libhmsbeagle/plugin/WinSharedLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ using namespace std;
class WinSharedLibrary : public SharedLibrary
{
public:
WinSharedLibrary(const char* name)
throw (SharedLibraryException);
WinSharedLibrary(const char* name);
~WinSharedLibrary();

void* findSymbol(const char* name)
throw (SharedLibraryException);
void* findSymbol(const char* name);

private:
HINSTANCE m_handle;
};
WinSharedLibrary::WinSharedLibrary(const char* name)
throw (SharedLibraryException)
: m_handle(0)
{
std::string libname = name;
Expand Down Expand Up @@ -78,9 +75,8 @@ WinSharedLibrary::~WinSharedLibrary()
}
}
void* WinSharedLibrary::findSymbol(const char* name)
throw (SharedLibraryException)
{
void* sym = GetProcAddress(m_handle,name);
void* sym = (void*)GetProcAddress(m_handle,name);
if (sym == 0)
{
char buffer[255];
Expand Down
Loading
Loading