Skip to content

Commit

Permalink
Merge pull request #1341 from albinahlback/unifytests
Browse files Browse the repository at this point in the history
Create unified tests
  • Loading branch information
fredrik-johansson authored Nov 1, 2023
2 parents d62ab4d + 93d92df commit aa91536
Show file tree
Hide file tree
Showing 3,282 changed files with 22,495 additions and 37,540 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
29 changes: 14 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
runs-on: ubuntu-latest

env:
MAKE: "make -j --output-sync=target"
CC: "gcc"
TESTCFLAGS: "-Wall -O1"
FLINT_TEST_MULTIPLIER: "10"

steps:
Expand All @@ -43,11 +41,12 @@ jobs:
make --version
autoconf --version
libtool --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
./bootstrap.sh
./configure CC=${CC} --enable-avx2 TESTCFLAGS="${TESTCFLAGS}" --disable-static --enable-coverage
./configure CC=${CC} --enable-avx2 --disable-static --enable-coverage
- name: "Compile library"
run: |
Expand Down Expand Up @@ -83,7 +82,6 @@ jobs:
runs-on: ubuntu-latest

env:
MAKE: "make -j --output-sync=target"
CC: "gcc"
CFLAGS: "-Wall -Werror=implicit-function-declaration"
FLINT_TEST_MULTIPLIER: "2"
Expand All @@ -101,6 +99,7 @@ jobs:
make --version
autoconf --version
libtool --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -135,7 +134,6 @@ jobs:
runs-on: macos-latest

env:
MAKE: "gmake -j -l 10 --output-sync=target"
CFLAGS: "-Wall"
EXTRA_OPTIONS: "--disable-static --enable-shared"
CC: "gcc"
Expand All @@ -157,6 +155,7 @@ jobs:
gcc --version
gmake --version
autoconf --version
echo "MAKE=gmake -j$(expr $(nproc) + 1) -l 10 --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -227,9 +226,9 @@ jobs:
--with-mpfr-include=$(pkgconf --variable=includedir mpfr) \
--with-mpfr-lib=$(pkgconf --variable=libdir mpfr)
touch _is_configured
gmake -j
gmake -j$(expr $(nproc) + 1)
touch _is_built
gmake -j check
gmake -j$(expr $(nproc) + 1) check
touch _is_checked
# Sometimes the FreeBSD runner cannot exit properly. We created files
Expand Down Expand Up @@ -287,7 +286,6 @@ jobs:
shell: C:\cygwin64\bin\bash.exe --login -o igncr '{0}'

env:
MAKE: "make -j --output-sync=target"
REPO: /cygdrive/d/a/flint/flint # FIXME: De-hardcode this
CFLAGS: "-Wall"
EXTRA_OPTIONS: "--enable-shared --disable-static"
Expand All @@ -308,6 +306,7 @@ jobs:
make --version
autoconf --version
libtool --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -347,7 +346,6 @@ jobs:
runs-on: ubuntu-latest

env:
MAKE: "make -j --output-sync=target"
LOCAL: ${{ github.workspace }}/local
LDFLAGS: "-Wl,-rpath,$LOCAL/lib"
CFLAGS: "-Wall"
Expand All @@ -368,6 +366,7 @@ jobs:
make --version
autoconf --version
libtool --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -402,7 +401,6 @@ jobs:
runs-on: ubuntu-latest

env:
MAKE: "make -j --output-sync=target"
LOCAL: ${{ github.workspace }}/local
LDFLAGS: "-Wl,-rpath,$LOCAL/lib"
CFLAGS: "-Wall"
Expand All @@ -418,6 +416,7 @@ jobs:
gcc --version
make --version
cmake --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -451,7 +450,6 @@ jobs:
shell: msys2 {0}

env:
MAKE: "make -j --output-sync=target"
CFLAGS: "-Wall"
EXTRA_OPTIONS: "--enable-shared --disable-static"
CC: "gcc"
Expand All @@ -473,6 +471,7 @@ jobs:
make --version
autoconf --version
libtool --version
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down Expand Up @@ -532,20 +531,20 @@ jobs:
cd build
set "LIB=C:\Miniconda3\Library\lib;%LIB%"
set "CPATH=C:\Miniconda3\Library\include;%CPATH%"
cmake -G "Ninja" -DCMAKE_C_FLAGS="/wd4018 /wd4146 /wd4244 /wd4267 /wd4305 /wd4996" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release ..
cmake -G "Ninja" -DCMAKE_C_FLAGS="/wd4018 /wd4146 /wd4244 /wd4267 /wd4305 /wd4996 /DFLINT_NO_CA_MAT_EXP_TEST" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release ..
- name: "Build"
run: |
cd build
cmake --build . -- -j4
cmake --build . -- -j3
# FIXME: Preferably drop support of CMake and native Windows, or fix so
# that we can include the test again.
- name: "Test everything except where MPIR fails"
run: |
cd build
set "FLINT_TEST_MULTIPLIER=1"
ctest -j4 --output-on-failure --timeout 180 -E "src-ca_mat-test-t-exp"
ctest -j3 --output-on-failure --timeout 450
- if: failure()
name: "If failure, stop all other jobs"
Expand All @@ -562,7 +561,6 @@ jobs:
runs-on: ubuntu-latest

env:
MAKE: "make -j --output-sync=target"
LOCAL: ${{ github.workspace }}/local
CFLAGS: ""
EXTRA_OPTIONS: "--disable-static --enable-shared"
Expand All @@ -582,6 +580,7 @@ jobs:
libtool --version
julia --version
julia -e 'println(Base.BinaryPlatforms.HostPlatform())'
echo "MAKE=make -j$(expr $(nproc) + 1) --output-sync=target" >> $GITHUB_ENV
- name: "Configure"
run: |
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ set_target_properties(flint

if(BUILD_TESTING)
enable_testing()
foreach (build_dir IN LISTS BUILD_DIRS CMAKE_CURRENT_SOURCE_DIR)
file(GLOB TEST_FILES "${build_dir}/test/*.c*")
foreach(test_file IN LISTS TEST_FILES)
foreach(build_dir IN LISTS BUILD_DIRS CMAKE_CURRENT_SOURCE_DIR)
file(GLOB test_file "${build_dir}/test/main.c")
if(test_file)
file(RELATIVE_PATH test_name ${CMAKE_CURRENT_SOURCE_DIR} ${test_file})
string(REPLACE "/" "-" test_name ${test_name})
get_filename_component(test_name ${test_name} NAME_WE)
Expand All @@ -391,7 +391,7 @@ if(BUILD_TESTING)
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
)
endforeach()
endif()
endforeach ()

if(WITH_NTL)
Expand Down
37 changes: 33 additions & 4 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ LDFLAGS:=@LDFLAGS@
EXTRA_SHARED_FLAGS:=@EXTRA_SHARED_FLAGS@ $(foreach path, $(GMP_LIB_PATH) $(MPFR_LIB_PATH) $(BLAS_LIB_PATH) $(GC_LIB_PATH) $(NTL_LIB_PATH), @WL@-rpath,$(path))
EXE_LDFLAGS:=$(LDFLAGS) $(foreach path, $(ABS_FLINT_DIR) $(GMP_LIB_PATH) $(MPFR_LIB_PATH) $(BLAS_LIB_PATH) $(GC_LIB_PATH) $(NTL_LIB_PATH), @WL@-rpath,$(path))

# Obtain level of parallel
JOBS:=$(filter -j%,$(MAKEFLAGS))
NJOBS:=$(patsubst -j%,%,$(JOBS))

# User may specify -j without specifying the number of jobs
ifneq ($(JOBS),)
ifeq ($(NJOBS),)
# TODO: Create a thing in autoconf in order to obtain the number of available
# cores when -j is specified without any number attached, such as `nproc`.
NJOBS:=8
endif
endif

################################################################################
################################################################################
# files and directories
Expand Down Expand Up @@ -257,11 +270,11 @@ $(foreach dir, $(DIRS), $(eval $(call xxx_PROF_SOURCES,$(dir))))
PROF_SOURCES := $(foreach dir,$(DIRS),$($(dir)_PROF_SOURCES)) $(_PROF_SOURCES)

# FIXME: De-hardcode fq_zech_vec from this.
fq_zech_vec_TEST_SOURCES := $(wildcard $(SRC_DIR)/fq_zech_vec/test/*.c)
fq_zech_vec_TEST_SOURCES := $(wildcard $(SRC_DIR)/fq_zech_vec/test/main.c)
define xxx_TEST_SOURCES
$(1)_TEST_SOURCES := $(wildcard $(SRC_DIR)/$(1)/test/*.c)
$(1)_TEST_SOURCES := $(wildcard $(SRC_DIR)/$(1)/test/main.c)
endef
_TEST_SOURCES := $(wildcard $(SRC_DIR)/test/*.c)
_TEST_SOURCES := $(wildcard $(SRC_DIR)/test/main.c)
$(foreach dir, $(DIRS), $(eval $(call xxx_TEST_SOURCES,$(dir))))
TEST_SOURCES := $(foreach dir,$(DIRS),$($(dir)_TEST_SOURCES)) $(_TEST_SOURCES) $(fq_zech_vec_TEST_SOURCES)
# NOTE: We do not add CPP files to C files in SOURCES in order to not screw up
Expand Down Expand Up @@ -662,12 +675,28 @@ tests: library $(TESTS)
%_TEST_RUN: %
@$<

# Parallel running of same test file
ifneq ($(NJOBS),)
number_generator=$(words $2) $(if $(word $1,$2),,$(call number_generator,$1,w $2))
THREAD_LIST:=$(call number_generator,$(NJOBS),w)

define xxx_test_run_parallel
%_TEST_RUN_$(1): %
@$$< --numthreads=$(NJOBS) --thread=$(1)
endef
$(foreach num, $(THREAD_LIST), $(eval $(call xxx_test_run_parallel,$(num))))
endif

ifdef PYTHON
check: library
PYTHONPATH=$(FLINT_DIR) python3 $(SRC_DIR)/python/flint_ctypes.py
else ifdef MOD
ifeq ($(NJOBS),)
check: library $(patsubst %,%_TEST_RUN,$(foreach dir, $(MOD), $($(dir)_TESTS)))
else
check: library $(foreach x_test,$(patsubst %,%_TEST_RUN,$(foreach dir,$(MOD),$($(dir)_TESTS))),$(foreach num,$(THREAD_LIST),$(x_test)_$(num)))
endif
else
check: library $(TESTS:%=%_TEST_RUN)
endif

Expand Down Expand Up @@ -696,7 +725,7 @@ endif

ifneq ($(COVERAGE), 0)
coverage: | $(BUILD_DIR)/coverage
lcov --capture --exclude "*test/t-*.c" --exclude "/usr/*" --directory $(BUILD_DIR) --output-file $(BUILD_DIR)/coverage/coverage.info
lcov --capture --exclude "*test/t-*.c" --exclude "*test/main.c" --exclude "/usr/*" --directory $(BUILD_DIR) --output-file $(BUILD_DIR)/coverage/coverage.info
genhtml $(BUILD_DIR)/coverage/coverage.info --output-directory $(BUILD_DIR)/coverage
endif

Expand Down
76 changes: 37 additions & 39 deletions doc/source/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ for instructions using CMake), FLINT can be built and installed as follows:
./bootstrap.sh
./configure --disable-static
make -j
make -j N
make install
We also recommend that you run ``make check`` before installing.
where ``N`` is the number of jobs number allowed to run parallel. Typically, the
fastest way to build is to let ``N`` be the number of threads your CPU plus one,
which can be obtained in Bash through ``$(expr $(nproc) + 1)``.

For a complete list of build settings, write
We also recommend that you check that the library works as it should through
``make check``, or ``make -j N check`` for a parallel check, before installing.

For a complete list of build settings, type

.. code-block:: bash
Expand Down Expand Up @@ -79,6 +84,11 @@ or in parallel on a multicore system using
make -j check
Here, ``make -j N check`` is typically the fastest way to build when ``N``
equals to the number of threads your system's CPU has plus one, that is,
``make -j $(expr $(nproc) + 1) check`` typically is the fastest way to check
FLINT.

Number of test iterations
...............................................................................

Expand All @@ -101,7 +111,21 @@ If you wish to simply check a single module of FLINT you can pass the option
.. code-block:: bash
make check MOD=ulong_extras
make check MOD="fft fmpz_mat"
make -j N check MOD="fft fmpz_mat"
Testing single functions
...............................................................................

Testing a single function is also possible, although one cannot utilize ``make``
all the way through for this. For example, if you would like to test the
function ``fmpz_add`` and ``fmpz_sub`` in the module ``fmpz``, you run

.. code-block:: bash
# Build all tests
make tests
# Run the test executable for `fmpz' with `fmpz_add' and `fmpz_sub' as inputs
./build/fmpz/test/main fmpz_add fmpz_sub
Test coverage
...............................................................................
Expand All @@ -112,7 +136,7 @@ FLINT with ``--enable-coverage``. Then run:

.. code-block:: bash
make -j check
make -j N check
make coverage
This will place a coverage report in ``build/coverage``.
Expand Down Expand Up @@ -143,15 +167,15 @@ reentrancy is required on systems that do not support this, one can pass
modern systems support thread local storage, it is not recommended to build
FLINT without TLS.

There are two modes in which FLINT may installed: the default ``single`` mode,
There are two modes in which FLINT may installed: the default "single" mode,
which is faster, but makes use of thread local storage for its memory manager
and to handle threading, and a slower but less complicated ``reentrant`` mode.
and to handle threading, and a slower but less complicated "reentrant" mode.
The later is useful when debugging a program where tracing allocations is
important.

If you wish to select the single mode, pass the ``--single`` option to
configure, though note that this is the default. The reentrant mode is selected
by passing the option ``--reentrant`` to configure.
If you wish to select the single mode, pass the ``--disable-reentrant`` option
to configure, though note that this is the default. The reentrant mode is
selected by passing the option ``--enable-reentrant`` to configure.

ABI and architecture support
-------------------------------------------------------------------------------
Expand All @@ -164,16 +188,9 @@ configure.
To build on MinGW64 it is necessary to pass ``ABI=64`` to configure, as FLINT
is otherwise unable to distinguish it from MinGW32.

In some cases, it is necessary to override the CPU/OS defaults. This can be
done by passing ``--build=cpu-os`` to configure.

The available choices for CPU include ``x86_64``, ``x86``, ``ia64``, ``sparc``,
``sparc64``, ``ppc``, ``ppc64``. Other CPU types are unrecognised and FLINT
will build with generic code on those machines.

The choices for OS include ``Linux``, ``MINGW32``, ``MINGW64``, ``CYGWIN32``,
``CYGWIN64``, ``Darwin``, ``FreeBSD``, ``SunOS`` and numerous other operating
systems.
In some cases, it is necessary to override the CPU/OS defaults. This can be done
by specifying the build system triplet to ``configure`` via
``--build=arch-vendor-os``.

It is also possible to override the default CC, AR and CFLAGS used by FLINT by
passing ``CC=full_path_to_compiler``, etc., to FLINT's configure.
Expand Down Expand Up @@ -258,22 +275,3 @@ The output of the example program should be something like the following::

[3.1415926535897932384626433832795028841971693993751 +/- 4.43e-50]
Computed with flint-3.0.0

Header file conflicts
-------------------------------------------------------------------------------

If you have any difficulties with conflicts with system headers on your
machine, you can do the following in your code:

.. code-block:: C
#undef ulong
#define ulong ulongxx
#include <stdio.h>
// other system headers
#undef ulong
#define ulong mp_limb_t
This prevents FLINT's definition of ``ulong`` interfering with your system
headers.

Loading

0 comments on commit aa91536

Please sign in to comment.