Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fab6b0f
Remove redundant CUDA synchronization
Nov 17, 2025
d9c1456
Ensure asynchronous GPU code has finished
Nov 17, 2025
dcb8fe8
Add a cmake-format configuration file
Nov 17, 2025
dc32df5
CMake: format a file with cmake-format
Nov 17, 2025
ed8a8af
cmake-format: avoid breaking early
Nov 18, 2025
0ebd091
Tests: revamp test creation
Nov 18, 2025
4f46d60
CI: execute tests not labelled 'long'
Nov 18, 2025
fe160f8
README: explain how to submit tests to batch scheduler
Nov 18, 2025
3230444
cmake-format: add custom parser for setup_test()
Nov 18, 2025
307a623
Tests: apply latest cmake-format config change
Nov 18, 2025
a5c5e2f
README: fix instructions tests w/ batch scheduler
Nov 24, 2025
428339a
README: use proper AsciiDoc
Nov 24, 2025
b9d036a
README: improve wording
Nov 24, 2025
f5fb2ff
CMake: avoid redundant operation
Nov 25, 2025
1f9ab6e
CMake: fix CMP0177 warnings
Nov 25, 2025
33dd1eb
CMake: enable test for ext_system
Nov 25, 2025
e692a11
Revert "CMake: avoid redundant operation"
Nov 25, 2025
1f29921
README: use ctest in reserved allocation
Dec 1, 2025
9931a95
CMake: avoid `env` as job name
Dec 2, 2025
cbeebde
CMake: elaborate on env/mpiexec interaction
Dec 2, 2025
2f13430
Merge branch '113-simplify-test-execution-on-cluster' into 'master'
Dec 2, 2025
9ceff7f
Merge branch '119-fix-cmp0177-warning' into 'master'
Dec 16, 2025
d1d22e6
Merge branch '112-check-for-missing-cuda-synchronization' into 'master'
Dec 18, 2025
577a6d8
elphinel.F90: fix typo
Feb 18, 2026
e5bbd9d
CI: check format of CMake, C++ files
Mar 10, 2026
758e296
CMake: run cmake-format
Mar 10, 2026
2b966c4
Tests: run clang-format
Mar 10, 2026
44ede43
GPU: run clang-format
Mar 10, 2026
54d2d97
Tests: make C++ code more idiomatic
Mar 10, 2026
cf65857
README: fix a typo
Mar 16, 2026
3362469
README: explain how to check code formatting
Mar 16, 2026
0717101
Fix error in readHS
pecchia Apr 17, 2026
3222d8e
CI: run all tests
Apr 23, 2026
ff109c9
Tests: update reference values
pecchia Apr 17, 2026
9f7961f
Tests: modify, fix Si n-i-n 40 PL test
pecchia Apr 17, 2026
ff5ab67
Merge branch '123-enforce-cmake-and-c-formatting' into 'master'
Apr 27, 2026
c8150b1
CI: run long tests only if short tests succeed
Apr 27, 2026
2493d8a
Tests: mark f90Si2x2 as long
Apr 27, 2026
ba3a623
Merge branch '124-fix-si_nin-40pls' into 'master'
Apr 27, 2026
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
243 changes: 243 additions & 0 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):

# Specify structure for custom cmake functions
additional_commands = {
'setup_test': { 'kwargs': {'GPUONLY': '0', 'LABELS': '+', 'MPI': '0', 'SOURCES': '+'},
'pargs': {'flags': ['2'], 'nargs': '0'}},
}

# Override configurations per-command where available
override_spec = {}

# Specify variable tags.
vartags = []

# Specify property tags.
proptags = []

# -----------------------------
# Options affecting formatting.
# -----------------------------
with section("format"):

# Disable formatting entirely, making cmake-format a no-op
disable = False

# How wide to allow formatted cmake files
line_width = 100

# How many spaces to tab for indent
tab_size = 2

# If true, lines are indented using tab characters (utf-8 0x09) instead of
# <tab_size> space characters (utf-8 0x20). In cases where the layout would
# require a fractional tab character, the behavior of the fractional
# indentation is governed by <fractional_tab_policy>
use_tabchars = False

# If <use_tabchars> is True, then the value of this variable indicates how
# fractional indentions are handled during whitespace replacement. If set to
# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
# to `round-up` fractional indentation is replaced with a single tab character
# (utf-8 0x09) effectively shifting the column to the next tabstop
fractional_tab_policy = 'use-space'

# If an argument group contains more than this many sub-groups (parg or kwarg
# groups) then force it to a vertical layout.
max_subgroups_hwrap = 2

# If a positional argument group contains more than this many arguments, then
# force it to a vertical layout.
max_pargs_hwrap = 6

# If a cmdline positional group consumes more than this many lines without
# nesting, then invalidate the layout (and nest)
max_rows_cmdline = 2

# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False

# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False

# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = True

# If the trailing parenthesis must be 'dangled' on its on line, then align it
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
# the start of the statement, plus one indentation level, `child`: align to
# the column of the arguments
dangle_align = 'prefix'

# If the statement spelling length (including space and parenthesis) is
# smaller than this amount, then force reject nested layouts.
min_prefix_chars = 4

# If the statement spelling length (including space and parenthesis) is larger
# than the tab width by more than this amount, then force reject un-nested
# layouts.
max_prefix_chars = 10

# If a candidate layout is wrapped horizontally but it exceeds this many
# lines, then reject the layout.
max_lines_hwrap = 2

# What style line endings to use in the output.
line_ending = 'unix'

# Format command names consistently as 'lower' or 'upper' case
command_case = 'canonical'

# Format keywords consistently as 'lower' or 'upper' case
keyword_case = 'unchanged'

# A list of command names which should always be wrapped
always_wrap = []

# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
enable_sort = True

# If true, the parsers may infer whether or not an argument list is sortable
# (without annotation).
autosort = False

# By default, if cmake-format cannot successfully fit everything into the
# desired linewidth it will apply the last, most aggressive attempt that it
# made. If this flag is True, however, cmake-format will print error, exit
# with non-zero status code, and write-out nothing
require_valid_layout = False

# A dictionary mapping layout nodes to a list of wrap decisions. See the
# documentation for more information.
layout_passes = {}

# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):

# What character to use for bulleted lists
bullet_char = '*'

# What character to use as punctuation after numerals in an enumerated list
enum_char = '.'

# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = False

# If comment markup is enabled, don't reflow any comment block which matches
# this (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None

# Regular expression to match preformat fences in comments default=
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'

# Regular expression to match rulers in comments default=
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'

# If a comment line matches starts with this pattern then it is explicitly a
# trailing comment for the preceding argument. Default is '#<'
explicit_trailing_pattern = '#<'

# If a comment line starts with at least this many consecutive hash
# characters, then don't lstrip() them off. This allows for lazy hash rulers
# where the first hash char is not separated by space
hashruler_min_length = 10

# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize its length to fill the column
canonicalize_hashrulers = True

# enable comment markup parsing and reflow
enable_markup = True

# ----------------------------
# Options affecting the linter
# ----------------------------
with section("lint"):

# a list of lint codes to disable
disabled_codes = []

# regular expression pattern describing valid function names
function_pattern = '[0-9a-z_]+'

# regular expression pattern describing valid macro names
macro_pattern = '[0-9A-Z_]+'

# regular expression pattern describing valid names for variables with global
# (cache) scope
global_var_pattern = '[A-Z][0-9A-Z_]+'

# regular expression pattern describing valid names for variables with global
# scope (but internal semantic)
internal_var_pattern = '_[A-Z][0-9A-Z_]+'

# regular expression pattern describing valid names for variables with local
# scope
local_var_pattern = '[a-z][a-z0-9_]+'

# regular expression pattern describing valid names for privatedirectory
# variables
private_var_pattern = '_[0-9a-z_]+'

# regular expression pattern describing valid names for public directory
# variables
public_var_pattern = '[A-Z][0-9A-Z_]+'

# regular expression pattern describing valid names for function/macro
# arguments and loop variables.
argument_var_pattern = '[a-z][a-z0-9_]+'

# regular expression pattern describing valid names for keywords used in
# functions or macros
keyword_pattern = '[A-Z][0-9A-Z_]+'

# In the heuristic for C0201, how many conditionals to match within a loop in
# before considering the loop a parser.
max_conditionals_custom_parser = 2

# Require at least this many newlines between statements
min_statement_spacing = 1

# Require no more than this many newlines between statements
max_statement_spacing = 2
max_returns = 6
max_branches = 12
max_arguments = 5
max_localvars = 15
max_statements = 50

# -------------------------------
# Options affecting file encoding
# -------------------------------
with section("encode"):

# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False

# Specify the encoding of the input file. Defaults to utf-8
input_encoding = 'utf-8'

# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = 'utf-8'

# -------------------------------------
# Miscellaneous configurations options.
# -------------------------------------
with section("misc"):

# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

15 changes: 14 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
MALLOC_PERTURB_: 1


check-format:
stage: .pre
image: $CI_REGISTRY/nexgf/libnegf/check-format
script:
- >-
find . -name CMakeLists.txt -print0
| xargs -0 -L1 -- cmake-format --check --
- >-
find . -iname '*.cu' -o -iname '*.cpp' -print0
| xargs -0 -L1 -- clang-format --dry-run -Werror --


build:
extends: .setup
stage: build
Expand Down Expand Up @@ -47,4 +59,5 @@ test:
stage: test
script:
- cd "$BUILD_DIR"
- ctest -L normal --output-on-failure
- ctest --output-on-failure -LE long
- ctest --output-on-failure -L long
54 changes: 33 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
cmake_minimum_required(VERSION 3.18)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.31)
cmake_policy(SET CMP0177 NEW)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(LibNegfUtils)
libnegf_load_build_settings()

# Some setting output
message(STATUS "libNEGF WITH_MPI: " ${WITH_MPI})
message(STATUS "libNEGF WITH_GPU: " ${WITH_TRANSPORT_GPU})
#message(STATUS "libNEGF WITH_HILBERT: " ${WITH_HILBERT})
# message(STATUS "libNEGF WITH_HILBERT: " ${WITH_HILBERT})

if(WITH_TRANSPORT_GPU)
project(libNEGF VERSION 1.2.1 LANGUAGES Fortran C CUDA CXX)
project(
libNEGF
VERSION 1.2.1
LANGUAGES Fortran C CUDA CXX
)
else()
project(libNEGF VERSION 1.2.1 LANGUAGES Fortran C CXX)
project(
libNEGF
VERSION 1.2.1
LANGUAGES Fortran C CXX
)
endif()


# disable compiler-specific extensions
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Note: enforcing a standard in Fortran compilers has a different effect that in C compilers, c.f. [cmake#22235](https://gitlab.kitware.com/cmake/cmake/-/issues/22235).

# Note: enforcing a standard in Fortran compilers has a different effect that in C compilers, c.f.
# [cmake#22235](https://gitlab.kitware.com/cmake/cmake/-/issues/22235).

include(externalMpifx)
include(CMakePackageConfigHelpers)


# find a Python3 interpreter for FYPP
include(FindPython3)
find_package(Python3 REQUIRED COMPONENTS Interpreter)


set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext_fypp/;${CMAKE_PREFIX_PATH}")
find_program(FYPP "fypp")

include(GNUInstallDirs)


if(LAPACK_LIBRARIES AND LAPACK_LIBRARY_DIRS)
message(STATUS "libNEGF LAPACK DIR: " ${LAPACK_LIBRARY_DIRS})
message(STATUS "libNEGF BLAS: " ${BLAS_LIBRARY})
Expand All @@ -53,7 +61,6 @@ if(WITH_MPI)
find_or_fetch_mpifx()
endif()


# Subdirectories.
add_subdirectory(ext_system)
add_subdirectory(src)
Expand All @@ -64,36 +71,41 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()


#
# Installation
#
set(CMAKE_INSTALL_PREFIX "/usr/local/libnegf${libNEGF_VERSION_MAJOR}.${libNEGF_VERSION_MINOR}" CACHE PATH
"default installation path")
set(CMAKE_INSTALL_PREFIX
"/usr/local/libnegf${libNEGF_VERSION_MAJOR}.${libNEGF_VERSION_MINOR}"
CACHE PATH "default installation path"
)

message(STATUS "Default installation path: " ${CMAKE_INSTALL_PREFIX})

add_library(Negf INTERFACE)
target_link_libraries(Negf INTERFACE negf)
install(TARGETS Negf EXPORT negf-targets)

install(EXPORT negf-targets
install(
EXPORT negf-targets
FILE negf-targets.cmake
NAMESPACE Negf::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/negf"
EXPORT_LINK_INTERFACE_LIBRARIES)
EXPORT_LINK_INTERFACE_LIBRARIES
)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/utils/export/negf-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/negf)
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/negf
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
COMPATIBILITY SameMajorVersion
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/negf)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/negf-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/negf
)
Loading