Skip to content
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
80 changes: 80 additions & 0 deletions .github/workflows/ci_modular.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on: [push, pull_request]

env:
CMAKE_BUILD_PARALLEL_LEVEL: "2" # 2 cores on each GHA VM, enable parallel builds
CTEST_OUTPUT_ON_FAILURE: "ON" # This way we don't need a flag to ctest
CTEST_PARALLEL_LEVEL: "2"
CTEST_TIME_TIMEOUT: "5" # some failures hang forever
HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
HOMEBREW_NO_AUTO_UPDATE: "ON"
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
HOMEBREW_NO_GITHUB_API: "ON"
HOMEBREW_NO_INSTALL_CLEANUP: "ON"

jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
toolchain:
- {compiler: gcc, version: 14}
build: [cmake]
with_bitsets: [On, Off]
env:
BUILD_DIR: ${{ matrix.build == 'cmake' && 'build' || '.' }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.x
uses: actions/setup-python@v5 # Use pip to install latest CMake, & FORD/Jin2For, etc.
with:
python-version: 3.x

- name: Install fypp
run: pip install --upgrade fypp ninja

- name: Setup Fortran compiler
uses: fortran-lang/setup-fortran@v1.6.2
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

# Build and test with built-in BLAS and LAPACK
- name: Configure with CMake
if: ${{ contains(matrix.build, 'cmake') }}
run: >-
cmake -Wdev -G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAXIMUM_RANK:String=4
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
-DFIND_BLAS:STRING=FALSE
-DWITH_BITSETS:STRING=${{ matrix.with_bitsets }}
-S . -B ${{ env.BUILD_DIR }}

- name: Build and compile
if: ${{ contains(matrix.build, 'cmake') }}
run: cmake --build ${{ env.BUILD_DIR }} --parallel

- name: catch build fail
if: ${{ failure() && contains(matrix.build, 'cmake') }}
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1

- name: test
if: ${{ contains(matrix.build, 'cmake') }}
run: >-
ctest
--test-dir ${{ env.BUILD_DIR }}
--parallel
--output-on-failure
--no-tests=error

- name: Install project
if: ${{ contains(matrix.build, 'cmake') }}
run: cmake --install ${{ env.BUILD_DIR }}
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ if(NOT DEFINED CMAKE_MAXIMUM_RANK)
set(CMAKE_MAXIMUM_RANK 4 CACHE STRING "Maximum array rank for generated procedures")
endif()

option(WITH_BITSETS "Compile STDLIB BITSETS" ON)

option(FIND_BLAS "Find external BLAS and LAPACK" ON)

# --- find external BLAS and LAPACK
Expand Down Expand Up @@ -118,6 +120,7 @@ endif()

list(
APPEND fyppFlags
"-DWITH_BITSETS=$<BOOL:${WITH_BITSETS}>"
"-DWITH_CBOOL=$<BOOL:${WITH_CBOOL}>"
"-DWITH_QP=$<BOOL:${WITH_QP}>"
"-DWITH_XDP=$<BOOL:${WITH_XDP}>"
Expand Down
3 changes: 3 additions & 0 deletions config/fypp_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def pre_process_fypp(args):
kwd.append("-DPROJECT_VERSION_MAJOR="+str(args.vmajor))
kwd.append("-DPROJECT_VERSION_MINOR="+str(args.vminor))
kwd.append("-DPROJECT_VERSION_PATCH="+str(args.vpatch))
if args.no_bitsets:
kwd.append("-DWITH_BITSETS=False")
if args.with_qp:
kwd.append("-DWITH_QP=True")
if args.with_xdp:
Expand Down Expand Up @@ -133,6 +135,7 @@ def fpm_build(args,unknown):

parser.add_argument("--njob", type=int, default=4, help="Number of parallel jobs for preprocessing")
parser.add_argument("--maxrank",type=int, default=4, help="Set the maximum allowed rank for arrays")
parser.add_argument("--no_bitsets",action='store_true', help="Include WITH_BITSETS=False in the command")
parser.add_argument("--with_qp",action='store_true', help="Include WITH_QP in the command")
parser.add_argument("--with_xdp",action='store_true', help="Include WITH_XDP in the command")
parser.add_argument("--with_ilp64",action='store_true', help="Include WITH_ILP64 to build 64-bit integer BLAS/LAPACK")
Expand Down
4 changes: 3 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ endmacro(ADD_EXAMPLE)
add_subdirectory(ansi)
add_subdirectory(array)
add_subdirectory(ascii)
add_subdirectory(bitsets)
if (WITH_BITSETS)
add_subdirectory(bitsets)
endif()
add_subdirectory(constants)
add_subdirectory(error)
add_subdirectory(hashmaps)
Expand Down
10 changes: 1 addition & 9 deletions example/math/example_math_swap.f90
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,4 @@ program example_math_swap
call swap(x,y)
end block

block
use stdlib_bitsets
type(bitset_64) :: x, y
call x%from_string('0000')
call y%from_string('1111')
call swap(x,y)
end block

end program example_math_swap
end program example_math_swap
2 changes: 2 additions & 0 deletions example/sorting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ ADD_EXAMPLE(sort)
ADD_EXAMPLE(sort_adjoint)
ADD_EXAMPLE(sort_index)
ADD_EXAMPLE(radix_sort)
if (WITH_BITSETS)
ADD_EXAMPLE(sort_bitset)
endif()
5 changes: 5 additions & 0 deletions include/common.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#:set WITH_XDP = False
#:endif

#! Support for bitsets
#:if not defined("WITH_BITSETS")
#:set WITH_BITSETS = True
#:endif

#! Support for linear algebra with 64-bit integer sizes
#:if not defined("WITH_ILP64")
#:set WITH_ILP64 = False
Expand Down
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
if (WITH_BITSETS)
add_subdirectory(bitsets)
endif()

add_subdirectory(blas)
add_subdirectory(lapack)

set(fppFiles
stdlib_ascii.fypp
stdlib_bitsets.fypp
stdlib_bitsets_64.fypp
stdlib_bitsets_large.fypp
stdlib_codata_type.fypp
stdlib_constants.fypp
stdlib_error.fypp
Expand Down Expand Up @@ -121,4 +122,7 @@ set(f90Files

configure_stdlib_target(${PROJECT_NAME} f90Files fppFiles cppFiles)

target_link_libraries(${PROJECT_NAME} PUBLIC blas lapack)
target_link_libraries(${PROJECT_NAME} PUBLIC
$<$<BOOL:${WITH_BITSETS}>:bitsets>
blas lapack)

9 changes: 9 additions & 0 deletions src/bitsets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(bitsets_fppFiles
../stdlib_kinds.fypp
../stdlib_optval.fypp
stdlib_bitsets.fypp
stdlib_bitsets_64.fypp
stdlib_bitsets_large.fypp
)

configure_stdlib_target(bitsets "" bitsets_fppFiles "")
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions src/stdlib_math.fypp
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#:include "common.fypp"
#:set IR_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES
#:set RC_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES

#:set IRB_KIND_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES

#:if WITH_BITSETS
#:set BITSET_KINDS_TYPES = list(zip(BITSET_KINDS, BITSET_TYPES))
#:set IRB_KIND_TYPES = IRB_KIND_TYPES + BITSET_KINDS_TYPES
#:endif

module stdlib_math
use stdlib_kinds, only: int8, int16, int32, int64, sp, dp, xdp, qp
use stdlib_optval, only: optval
#:if WITH_BITSETS
use stdlib_bitsets, only: bitset_64, bitset_large
#:endif

implicit none
private
Expand Down Expand Up @@ -48,7 +57,7 @@ module stdlib_math
!>
!> Version: experimental
interface swap
#:for k1, t1 in INT_KINDS_TYPES + REAL_KINDS_TYPES + BITSET_KINDS_TYPES
#:for k1, t1 in IRB_KIND_TYPES
module procedure :: swap_${k1}$
#:endfor
#:for k1, t1 in CMPLX_KINDS_TYPES
Expand Down Expand Up @@ -527,7 +536,7 @@ contains

#:endfor

#:for k1, t1 in INT_KINDS_TYPES + REAL_KINDS_TYPES + BITSET_KINDS_TYPES
#:for k1, t1 in IRB_KIND_TYPES
elemental subroutine swap_${k1}$(lhs, rhs)
${t1}$, intent(inout) :: lhs, rhs
${t1}$ :: temp
Expand Down
11 changes: 8 additions & 3 deletions src/stdlib_sorting.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
#:set REAL_TYPES_ALT_NAME = list(zip(REAL_TYPES, REAL_TYPES, REAL_KINDS))
#:set STRING_TYPES_ALT_NAME = list(zip(STRING_TYPES, STRING_TYPES, STRING_KINDS))
#:set CHAR_TYPES_ALT_NAME = list(zip(["character(len=*)"], ["character(len=len(array))"], ["char"]))
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))

#:set INT_INDEX_TYPES_ALT_NAME = list(zip(["int_index", "int_index_low"], ["integer(int_index)", "integer(int_index_low)"], ["default", "low"]))

#! For better code reuse in fypp, make lists that contain the input types,
#! with each having output types and a separate name prefix for subroutines
#! This approach allows us to have the same code for all input types.
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME &
& + BITSET_TYPES_ALT_NAME
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME
#:set IR_INDEX_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME

#:if WITH_BITSETS
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))
#:set IRSCB_TYPES_ALT_NAME = IRSCB_TYPES_ALT_NAME + BITSET_TYPES_ALT_NAME
#:endif

!! Licensing:
!!
!! This file is subject both to the Fortran Standard Library license, and
Expand Down Expand Up @@ -134,8 +137,10 @@ module stdlib_sorting
use stdlib_string_type, only: string_type, assignment(=), operator(>), &
operator(>=), operator(<), operator(<=)

#:if WITH_BITSETS
use stdlib_bitsets, only: bitset_64, bitset_large, &
assignment(=), operator(>), operator(>=), operator(<), operator(<=)
#:endif

implicit none
private
Expand Down
9 changes: 6 additions & 3 deletions src/stdlib_sorting_ord_sort.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#:set REAL_TYPES_ALT_NAME = list(zip(REAL_TYPES, REAL_TYPES, REAL_TYPES, REAL_KINDS))
#:set STRING_TYPES_ALT_NAME = list(zip(STRING_TYPES, STRING_TYPES, STRING_TYPES, STRING_KINDS))
#:set CHAR_TYPES_ALT_NAME = list(zip(["character(len=*)"], ["character(len=:)"], ["character(len=len(array))"], ["char"]))
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))

#! For better code reuse in fypp, make lists that contain the input types,
#! with each having output types and a separate name prefix for subroutines
#! This approach allows us to have the same code for all input types.
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME &
& + BITSET_TYPES_ALT_NAME
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME

#:if WITH_BITSETS
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))
#:set IRSCB_TYPES_ALT_NAME = IRSCB_TYPES_ALT_NAME + BITSET_TYPES_ALT_NAME
#:endif

#:set SIGN_NAME = ["increase", "decrease"]
#:set SIGN_TYPE = [">", "<"]
Expand Down
9 changes: 6 additions & 3 deletions src/stdlib_sorting_sort.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#:set REAL_TYPES_ALT_NAME = list(zip(REAL_TYPES, REAL_TYPES, REAL_KINDS))
#:set STRING_TYPES_ALT_NAME = list(zip(STRING_TYPES, STRING_TYPES, STRING_KINDS))
#:set CHAR_TYPES_ALT_NAME = list(zip(["character(len=*)"], ["character(len=len(array))"], ["char"]))
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))

#! For better code reuse in fypp, make lists that contain the input types,
#! with each having output types and a separate name prefix for subroutines
#! This approach allows us to have the same code for all input types.
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME &
& + BITSET_TYPES_ALT_NAME
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME

#:if WITH_BITSETS
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))
#:set IRSCB_TYPES_ALT_NAME = IRSCB_TYPES_ALT_NAME + BITSET_TYPES_ALT_NAME
#:endif

#:set SIGN_NAME = ["increase", "decrease"]
#:set SIGN_TYPE = [">", "<"]
Expand Down
9 changes: 6 additions & 3 deletions src/stdlib_sorting_sort_adjoint.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
#:set REAL_TYPES_ALT_NAME = list(zip(REAL_TYPES, REAL_TYPES, REAL_TYPES, REAL_KINDS))
#:set STRING_TYPES_ALT_NAME = list(zip(STRING_TYPES, STRING_TYPES, STRING_TYPES, STRING_KINDS))
#:set CHAR_TYPES_ALT_NAME = list(zip(["character(len=*)"], ["character(len=:)"], ["character(len=len(array))"], ["char"]))
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))

#! For better code reuse in fypp, make lists that contain the input types,
#! with each having output types and a separate name prefix for subroutines
#! This approach allows us to have the same code for all input types.
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME &
& + BITSET_TYPES_ALT_NAME
#:set IRSCB_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME + STRING_TYPES_ALT_NAME + CHAR_TYPES_ALT_NAME
#:set IR_INDEX_TYPES_ALT_NAME = INT_TYPES_ALT_NAME + REAL_TYPES_ALT_NAME

#:if WITH_BITSETS
#:set BITSET_TYPES_ALT_NAME = list(zip(BITSET_TYPES, BITSET_TYPES, BITSET_TYPES, BITSET_KINDS))
#:set IRSCB_TYPES_ALT_NAME = IRSCB_TYPES_ALT_NAME + BITSET_TYPES_ALT_NAME
#:endif

!! Licensing:
!!
!! This file is subjec† both to the Fortran Standard Library license, and
Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ endmacro(ADDTESTPP)

add_subdirectory(array)
add_subdirectory(ascii)
add_subdirectory(bitsets)
if (WITH_BITSETS)
add_subdirectory(bitsets)
endif()
add_subdirectory(constants)
add_subdirectory(hash_functions)
add_subdirectory(hash_functions_perf)
Expand Down
2 changes: 2 additions & 0 deletions test/math/test_stdlib_math.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ contains
if (allocated(error)) return
end subroutine test_swap_stt

#:if WITH_BITSETS
subroutine test_swap_bitset_64(error)
use stdlib_bitsets
type(error_type), allocatable, intent(out) :: error
Expand Down Expand Up @@ -415,6 +416,7 @@ contains
call check(error, x == v )
if (allocated(error)) return
end subroutine test_swap_bitset_large
#:endif

#:for k1 in CMPLX_KINDS
subroutine test_arg_${k1}$(error)
Expand Down
Loading
Loading