Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeulen authored Feb 9, 2024
2 parents 1c10049 + b7865c8 commit 05421fc
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 33 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/conda-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Conda Build

on:
push:
branches:
- development

jobs:
build-linux:
name: CondaBuild (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.11"]
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true

- name: Display Conda Settings
shell: bash -el {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Build Conda Package
shell: bash -el {0}
run: |
mamba install conda-build boa
cd conda-recipe
curl -sLO https://raw.githubusercontent.com/conda-forge/conda-forge-pinning-feedstock/084b098a28a7a66e9a0967d156bc55b9ebfc6726/recipe/conda_build_config.yaml
# curl -sLO https://github.com/conda-forge/conda-forge-pinning-feedstock/raw/main/recipe/conda_build_config.yaml
conda mambabuild .
56 changes: 56 additions & 0 deletions .github/workflows/conda-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

name: Build and Upload Conda Packages

on:
# push:
# branches:
# - develop
release:
types: ['released', 'prereleased']

jobs:
build:
name: CondaBuild (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true

- name: Display Conda Settings
shell: bash -el {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Build Conda Package
shell: bash -el {0}
run: |
mamba install conda-build boa anaconda-client
cd conda-recipe
# Use older conda_build_config -> boost-cpp 1.78
curl -sLO https://raw.githubusercontent.com/conda-forge/conda-forge-pinning-feedstock/084b098a28a7a66e9a0967d156bc55b9ebfc6726/recipe/conda_build_config.yaml
# curl -sLO https://github.com/conda-forge/conda-forge-pinning-feedstock/raw/main/recipe/conda_build_config.yaml
conda mambabuild conda-recipe --output-folder conda-bld
- name: Upload Conda Package
shell: bash -el {0}
run: |
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload -u tpeulen --force conda-bld/**/*.tar.bz2
22 changes: 22 additions & 0 deletions .github/workflows/gitlab-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: GitlabSync

on:
- push
- delete

jobs:
sync:
runs-on: ubuntu-latest
name: Git Repo Sync
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wangchucheng/[email protected]
with:
# Such as https://github.com/wangchucheng/git-repo-sync.git
target-url: ${{ secrets.TARGET_URL }}
# Such as wangchucheng
target-username: ${{ secrets.TARGET_USERNAME }}
# You can store token in your project's 'Setting > Secrets' and reference the name here. Such as ${{ secrets.ACCESS\_TOKEN }}
target-token: ${{ secrets.TARGET_TOKEN }}
54 changes: 33 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)
SET(PROJECT_NAME fit2x)
PROJECT(${PROJECT_NAME})
ENABLE_LANGUAGE(CXX)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD 17)
ADD_DEFINITIONS(-D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)

################################################################################
Expand Down Expand Up @@ -40,32 +40,37 @@ IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")

if(LINUX)
STRING(APPEND CMAKE_CXX_FLAGS " -Ofast -ffast-math -funroll-loops")
STRING(APPEND CMAKE_C_FLAGS " -Ofast -ffast-math -funroll-loops")
endif()
if(APPLE)
# SIMD
###########################
IF(NOT APPLE)
IF(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/dependency)
INCLUDE(simd)
IF(${AVX_FOUND})
MESSAGE("BUILD WITH SIMD")
add_compile_definitions(WITH_AVX)
IF (MSVC)
# https://devblogs.microsoft.com/cppblog/simd-extension-to-c-openmp-in-visual-studio/
# /Oi is for intrinsics
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -openmp:experimental /Oi")
ELSE(MSVC)
STRING(APPEND CMAKE_CXX_FLAGS " -Ofast -mavx -mfma -ffast-math -funroll-loops")
ENDIF (MSVC)
ELSE(${AVX_FOUND})
UNSET(WITH_AVX)
ENDIF(${AVX_FOUND})
ENDIF()
ENDIF()

# MACOSX
##############
if (APPLE)
FIND_PACKAGE(Threads)
# explicit link to libc++ for recent osx versions
MESSAGE(STATUS "Explicitly link to libc++ on modern osx versions")
ADD_DEFINITIONS(-stdlib=libc++)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
# Requires AVX and FMA
STRING(APPEND CMAKE_CXX_FLAGS " -Ofast -ffast-math -funroll-loops")
STRING(APPEND CMAKE_C_FLAGS " -Ofast -ffast-math -funroll-loops")
endif()
if (MSVC)
ADD_DEFINITIONS(-DMS_WIN64)
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
# https://devblogs.microsoft.com/cppblog/simd-extension-to-c-openmp-in-visual-studio/
# /Oi is for intrinsics
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -openmp:experimental /Oi /O2")
endif (MSVC)

# MACOSX
##############
if (APPLE)
# Don't set MACOSX_RPATH by default
# https://github.com/conda/conda/issues/3624
if(DEFINED ENV{CONDA_PREFIX})
Expand Down Expand Up @@ -101,6 +106,13 @@ ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release")
###### INCLUDES AND LIBRARIES
################################################################################

# third party includes/code
FILE(GLOB_RECURSE SRC_files_thirdparty "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/*.cpp")
LIST(APPEND SRC_files ${SRC_files_thirdparty})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)

## CONDA
###########################
FIND_PACKAGE(Conda)
LINK_LIBRARIES(tttrlib)

Expand Down
9 changes: 5 additions & 4 deletions src/fsconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void fconv_per(double *fit, double *x, double *lamp, int numexp, int start, int
// fast convolution, high repetition rate, AVX
void fconv_per_avx(double *fit, double *x, double *lamp, int numexp, int start, int stop,
int n_points, double period, double dt) {

#ifdef __AVX2__
#if VERBOSE_FIT2X
std::clog << "fconv_per_avx" << std::endl;
Expand Down Expand Up @@ -493,7 +494,7 @@ void fconv_per_cs_time_axis(
double period
){
double dt = time_axis[1] - time_axis[0];
#ifdef __AVX2__
#ifdef WITH_AVX
fconv_per_avx(
model,
lifetime_spectrum,
Expand All @@ -504,7 +505,7 @@ void fconv_per_cs_time_axis(
period, dt
);
#endif
#ifndef __AVX2__
#ifndef WITH_AVX
fconv_per(
model, lifetime_spectrum, instrument_response_function, (int) n_lifetime_spectrum / 2,
convolution_start, convolution_stop, n_model, period, dt
Expand All @@ -523,7 +524,7 @@ void fconv_cs_time_axis(
int convolution_stop
){
double dt = time_axis[1] - time_axis[0];
#ifdef __AVX2__
#ifdef WITH_AVX
fconv_avx(
output,
lifetime_spectrum,
Expand All @@ -532,7 +533,7 @@ void fconv_cs_time_axis(
convolution_start, convolution_stop, dt
);
#endif
#ifndef __AVX2__
#ifndef WITH_AVX
fconv(
output,
lifetime_spectrum,
Expand Down
11 changes: 3 additions & 8 deletions test/test_fsconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def test_fconv(self):
np.allclose(model_ref, model_fconv), True
)

# AVX wont be supported on Apple -> M1
if platform != "darwin":
model_fconv_avx = np.zeros_like(irf)
fit2x.fconv_avx(
Expand All @@ -140,9 +139,7 @@ def test_fconv(self):
x=lifetime_spectrum,
dt=dt
)
self.assertEqual(
np.allclose(model_fconv_avx, model_fconv), True
)
np.testing.assert_allclose(model_fconv_avx, model_fconv)

def test_fconv_per(self):
period = 13.0
Expand Down Expand Up @@ -190,7 +187,7 @@ def test_fconv_per(self):
np.allclose(model_fconv_per, ref), True
)

# AVX wont be supported on Apple -> M1
# AVX won't be supported on Apple -> M1
if platform != "darwin":
model_fconv_avx = np.zeros_like(irf)
fit2x.fconv_per_avx(
Expand Down Expand Up @@ -248,9 +245,7 @@ def test_fconv_per_cs(self):
# plt.semilogy(irf)
# plt.show()

self.assertEqual(
np.allclose(ref, model_fconv_per_cs), True
)
np.testing.assert_allclose(ref, model_fconv_per_cs)

# def test_sconv(self):
# period = 12.0
Expand Down

0 comments on commit 05421fc

Please sign in to comment.