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
56 changes: 45 additions & 11 deletions .github/workflows/msolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,35 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
include:
- { os: ubuntu-latest, shell: bash }
- { os: macos-latest, shell: bash }
- { os: windows-latest, shell: msys2 }
defaults:
run:
shell: ${{ matrix.shell }} {0}
steps:
- name: Disable CRLF conversion on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v6
- name: Set up MSYS2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
- name: "Install dependencies"
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
# sharutils is for uudecode
sudo apt install libgmp-dev libflint-dev libmpfr-dev libntl-dev
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install autoconf automake libtool gmp flint mpfr ntl
elif [ "$RUNNER_OS" == "Windows" ]; then
pacman -S --noconfirm autotools mingw-w64-x86_64-toolchain mingw-w64-x86_64-gmp mingw-w64-x86_64-flint mingw-w64-x86_64-mpfr mingw-w64-x86_64-ntl
else
echo "$RUNNER_OS not supported"
exit 1
Expand All @@ -33,7 +50,7 @@ jobs:
run: ./autogen.sh
- name: configure
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "Windows" ]; then
./configure
elif [ "$RUNNER_OS" == "macOS" ]; then
./configure LDFLAGS="-L$(brew --prefix)/lib/" \
Expand All @@ -51,7 +68,7 @@ jobs:
run: cat test-suite.log || true
- name: make distcheck
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "Windows" ]; then
make distcheck
elif [ "$RUNNER_OS" == "macOS" ]; then
make distcheck LDFLAGS="-L$(brew --prefix)/lib/" \
Expand All @@ -66,22 +83,39 @@ jobs:

build-fixed-seed:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
include:
- { os: ubuntu-latest, shell: bash }
- { os: macos-latest, shell: bash }
- { os: windows-latest, shell: msys2 }
defaults:
run:
shell: ${{ matrix.shell }} {0}
steps:
- name: Disable CRLF conversion on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v6
- name: Set up MSYS2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
- name: "Install dependencies"
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
# sharutils is for uudecode
sudo apt install libgmp-dev libflint-dev libmpfr-dev libntl-dev
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install autoconf automake libtool gmp flint mpfr ntl
elif [ "$RUNNER_OS" == "Windows" ]; then
pacman -S --noconfirm autotools mingw-w64-x86_64-toolchain mingw-w64-x86_64-gmp mingw-w64-x86_64-flint mingw-w64-x86_64-mpfr mingw-w64-x86_64-ntl
else
echo "$RUNNER_OS not supported"
exit 1
Expand All @@ -90,7 +124,7 @@ jobs:
run: ./autogen.sh
- name: configure
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "Windows" ]; then
./configure
elif [ "$RUNNER_OS" == "macOS" ]; then
./configure LDFLAGS="-L$(brew --prefix)/lib/" \
Expand All @@ -108,7 +142,7 @@ jobs:
run: cat test-suite.log || true
- name: make distcheck with fixed seed
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "Windows" ]; then
make distcheck DISTCHECK_CONFIGURE_FLAGS="SEED=1617753600"
elif [ "$RUNNER_OS" == "macOS" ]; then
make distcheck LDFLAGS="-L$(brew --prefix)/lib/" \
Expand Down
1 change: 1 addition & 0 deletions src/fglm/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ libfglm_la_CFLAGS = $(SIMD_FLAGS) $(CPUEXT_FLAGS) $(OPENMP_CFLAGS) -Wall -Wextr

EXTRA_DIST = fglm.h \
libfglm.h \
aligned_alloc.h \
berlekamp_massey.c \
data_fglm.c \
fglm_core.c \
Expand Down
50 changes: 50 additions & 0 deletions src/fglm/aligned_alloc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* This file is part of msolve.
*
* msolve is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* msolve is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with msolve. If not, see <https://www.gnu.org/licenses/>
*
* Authors:
* Jérémy Berthomieu
* Christian Eder
* Mohab Safey El Din */

#ifndef ALIGNED_ALLOC_HEADER_H
#define ALIGNED_ALLOC_HEADER_H

#ifdef _WIN32

#include <errno.h>
#include <malloc.h>

static inline int posix_memalign(void **__memptr, size_t __alignment, size_t __size)
{
void *p = _aligned_malloc(__size, __alignment);
if (!p)
{
return ENOMEM;
}
*__memptr = p;
return 0;
}
#endif

static inline void posix_memalign_free(void *__p)
{
#ifdef _WIN32
_aligned_free(__p);
#else
free(__p);
#endif
}

#endif /* ALIGNED_ALLOC_HEADER_H */
19 changes: 10 additions & 9 deletions src/fglm/data_fglm.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
#include <flint/nmod_poly_factor.h>
#include <flint/ulong_extras.h>

#include "aligned_alloc.h"

static inline void free_sp_mat_fglm(sp_matfglm_t *mat){
if(mat!=NULL){
free(mat->dense_mat);
free(mat->triv_idx);
free(mat->triv_pos);
free(mat->dense_idx);
free(mat->dst);
posix_memalign_free(mat->dense_mat);
posix_memalign_free(mat->triv_idx);
posix_memalign_free(mat->triv_pos);
posix_memalign_free(mat->dense_idx);
posix_memalign_free(mat->dst);
free(mat);
}
}
Expand Down Expand Up @@ -80,10 +81,10 @@ static inline fglm_data_t *allocate_fglm_data(szmat_t nrows, szmat_t ncols, szma


static inline void free_fglm_data(fglm_data_t *data){
free(data->vecinit);
free(data->res);
free(data->vecmult);
free(data->vvec);
posix_memalign_free(data->vecinit);
posix_memalign_free(data->res);
posix_memalign_free(data->vecmult);
posix_memalign_free(data->vvec);
free(data->pts);
free(data);
}
Expand Down
14 changes: 8 additions & 6 deletions src/fglm/fglm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ double omp_get_wtime(void) { return realtime();}
#include "../upolmat/nmod_poly_mat_pmbasis.c"
#endif

#include "aligned_alloc.h"

void print_fglm_data(
FILE *file,
const md_t * const st,
Expand Down Expand Up @@ -613,9 +615,9 @@ static void generate_matrix_sequence(sp_matfglm_t *matxn, fglm_data_t *data,
exit(1);
#endif
}
free(Rmat);
free(res);
free(tres);
posix_memalign_free(Rmat);
posix_memalign_free(res);
posix_memalign_free(tres);

}
#endif
Expand Down Expand Up @@ -1337,7 +1339,7 @@ param_t *nmod_fglm_compute_trace_data(sp_matfglm_t *matrix, mod_t prime,
#endif

#if DEBUGFGLM >= 1
FILE *fmat = fopen("/tmp/matrix.fglm", "w");
FILE *fmat = fopen("/tmp/matrix.fglm", "wb");
display_fglm_matrix(fmat, matrix);
fclose(fmat);
#endif
Expand Down Expand Up @@ -1539,7 +1541,7 @@ int nmod_fglm_compute_apply_trace_data(sp_matfglm_t *matrix,
#endif

#if DEBUGFGLM >= 1
FILE *fmat = fopen("/tmp/matrix.fglm", "w");
FILE *fmat = fopen("/tmp/matrix.fglm", "wb");
display_fglm_matrix(fmat, matrix);
fclose(fmat);
#endif
Expand Down Expand Up @@ -1758,7 +1760,7 @@ param_t *nmod_fglm_guess_colon(sp_matfglmcol_t *matrix,
#endif

#if DEBUGFGLM >= 1
FILE *fmat = fopen("/tmp/matrix.fglm", "w");
FILE *fmat = fopen("/tmp/matrix.fglm", "wb");
display_fglm_colon_matrix(fmat, matrix);
fclose(fmat);
#endif
Expand Down
1 change: 1 addition & 0 deletions src/msolve/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ libmsolve_la_LIBADD = ../usolve/libusolve.la ../fglm/libfglm.la ../neogb/libneo

EXTRA_DIST = msolve-data.h \
msolve.h \
getdelim.h \
msolve-data.c \
duplicate.c \
hilbert.c \
Expand Down
Loading
Loading