Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] porting HPAC DLP kernel code into LinBox #241

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

ACLOCAL_AMFLAGS = -I macros

SUBDIRS=linbox benchmarks macros tests interfaces doc examples
SUBDIRS=linbox benchmarks macros tests interfaces doc examples programs

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = linbox.pc
Expand Down Expand Up @@ -64,7 +64,10 @@ benchmarks/perfpublisher:
tests/perfpublisher:
(cd tests; ${MAKE} perfpublisher)

.PHONY:examples benchmarks
programs:
(cd programs; ${MAKE} programs)

.PHONY:examples benchmarks programs

bin_SCRIPTS=linbox-config

Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ benchmarks/Makefile
benchmarks/data/Makefile
benchmarks/matrix/Makefile
programs/Makefile
programs/kernelvector/Makefile
programs/kernelvector/bin/Makefile
programs/kernelvector/src/Makefile
programs/kernelvector/include/Makefile
programs/smith/Makefile
linbox.pc
])
Expand Down
20 changes: 13 additions & 7 deletions linbox/algorithms/polynomial-matrix/order-basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
//#define __CHECK_ORDERBASIS
//#define __DEBUG_MBASIS

#ifdef __MINPOLY_SETTING
#define PROFILE_PMBASIS
#define LOW_MEMORY_PMBASIS
#define TRACK_MEMORY_MATPOL
// #define __CHECK_PMBASIS
// #define __PROBA_CHECK
// #define __CHECK_PMBASIS_THRESHOLD 1023
// #define
// #define __DUMP_ORDERBASIS
#endif



#ifndef __LINBOX_ORDER_BASIS
#define __LINBOX_ORDER_BASIS
Expand All @@ -52,13 +64,7 @@
namespace LinBox {


#ifdef __MINPOLY_SETTING
#define __CHECK_PMBASIS
#define __PROBA_CHECK
#define __DUMP_ORDERBASIS
#define __CHECK_PMBASIS_THRESHOLD 1023
#define PROFILE_PMBASIS
#endif



#ifdef __CHECK_ORDERBASIS
Expand Down
5 changes: 3 additions & 2 deletions programs/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SUBDIRS=smith
SUBDIRS=smith kernelvector

programs:
(cd smith; ${MAKE} programs)
(cd kernelvector; ${MAKE} programs)
(cd smith; ${MAKE} programs)
28 changes: 28 additions & 0 deletions programs/kernelvector/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2019 the LinBox group
# This file is part of LinBox
# ========LICENCE========
# This file is part of the library LinBox.
#
# LinBox is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# ========LICENCE========
#/
SUBDIRS=bin src include

programs:
(cd bin; ${MAKE} programs)

EXTRA_DIST=\
left-kernel.sh \
right_kernel.sh
61 changes: 61 additions & 0 deletions programs/kernelvector/bin/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2010 the LinBox group
# This file is part of LinBox
# ========LICENCE========
# This file is part of the library LinBox.
#
# LinBox is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# ========LICENCE========
#/


#FLAG128=-D__USE_128bits -D__USE_SIMD=0


DEFCPPFLAGS = @DEFAULT_CFLAGS@ -DDISABLE_COMMENTATOR
AM_CPPFLAGS = -I$(top_srcdir) $(DEFCPPFLAGS) $(DEPS_CFLAGS)
AM_CPPFLAGS += $(OPTFLAGS) -I../include $(FLAG128) -DLINBOX_DEBUG -DGIVARO_DEBUG -DFFLASFFPACK_DEBUG -UNDEBUG -DDEBUG
LDADD = $(DEPS_LIBS) $(LDFLAGS)
LDADD += $(top_builddir)/linbox/liblinbox.la
LDADD += $(OPTLIBES)

PROGS=evaluation_build_kernel minpoly_minpoly verif_g0kernel evaluation_evaluation\
sequence_decomp_kernel verif_par_verif evaluation_finalchecks\
sequence_sequence verif_precompute evaluation_g0kernel sequence_transpose\
verif_verif_minpoly

EXTRA_PROGRAMS= $(PROGS)

CLEANFILES=$(EXTRA_PROGRAMS)


programs: ${EXTRA_PROGRAMS}

evaluation_build_kernel_SOURCES= ../src/evaluation_build_kernel.cpp
minpoly_minpoly_SOURCES= ../src/minpoly_minpoly.cpp
verif_g0kernel_SOURCES= ../src/verif_g0kernel.cpp
evaluation_evaluation_SOURCES= ../src/evaluation_evaluation.cpp
sequence_decomp_kernel_SOURCES= ../src/sequence_decomp_kernel.cpp
verif_par_verif_SOURCES= ../src/verif_par_verif.cpp
evaluation_finalchecks_SOURCES= ../src/evaluation_finalchecks.cpp
sequence_sequence_SOURCES= ../src/sequence_sequence.cpp
verif_precompute_SOURCES= ../src/verif_precompute.cpp
evaluation_g0kernel_SOURCES= ../src/evaluation_g0kernel.cpp
sequence_transpose_SOURCES= ../src/sequence_transpose.cpp
verif_verif_minpoly_SOURCES= ../src/verif_verif_minpoly.cpp

LINBOX=@prefix@

LINBOX_BIN=@bindir@

34 changes: 34 additions & 0 deletions programs/kernelvector/include/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2019 the LinBox group
# This file is part of LinBox
# ========LICENCE========
# This file is part of the library LinBox.
#
# LinBox is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# ========LICENCE========
#/

EXTRA_DIST = \
common_define.hpp \
common_kernel.hpp \
common_sdm.hpp \
common_sdmp.hpp \
evaluation_gemv.hpp \
verif_read.hpp \
common_common.hpp \
common_dv.hpp \
common_read.hpp \
common_sdmb.hpp \
common_spmm.hpp \
verif_define.hpp
83 changes: 83 additions & 0 deletions programs/kernelvector/include/common_common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* Copyright (c) 2015 HPAC
* Written by Alexis Breust <[email protected]>
* Jean-Guillaume Dumas <[email protected]>
*/

#pragma once
#include <recint/rint.h>
#include <recint/ruint.h>

#include <cstdint>
#include <string>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> // std::setw()

//--------------------//
//----- Typedefs -----//

#ifdef __USE_128bits
using Element_t = RecInt::rint128;
using Modulus_t = RecInt::rint128;
#define __DLP_ABS(a) ((a)<0?-(a):(a))
#else
using Element_t = int64_t; // Sufficiently large to store a (field) element.
using Modulus_t = int64_t; // Sufficiently large to store the modulus.
#define __DLP_ABS(a) std::abs(a)
#endif
using Index_t = uint64_t; // Sufficiently large to store an array index.
using Size_t = uint64_t; // Sufficiently large to store an array size.

//-----------------//
//----- Utils -----//

inline std::string formatNumber(const Index_t n)
{
std::stringstream str;
// Note: 20 is base ten max number of digits for a 64-bits number.
str << "_" << std::setw(20) << std::setfill('0') << n;
return str.str();
}

//----------------//
//----- Info -----//

inline
void saveInfo(const std::string& filename, const std::string& matrixFile, Modulus_t q,
Size_t m, Size_t n, Size_t s1, Size_t s2, Size_t d, Size_t K)
{
std::ofstream infoFile(filename);
if (!infoFile.is_open())
throw std::runtime_error("Cannot open info file.");

infoFile << "matrixFile: " << matrixFile << std::endl;
infoFile << "modulus: " << q << std::endl;
infoFile << "nRows: " << m << std::endl;
infoFile << "nCols: " << n << std::endl;
infoFile << "s1: " << s1 << std::endl;
infoFile << "s2: " << s2 << std::endl;
infoFile << "sequenceLength: " << d << std::endl;
infoFile << "checkpointsStep: " << K << std::endl;
}

inline
void loadInfo(const std::string& filename, std::string& matrixFile, Modulus_t& q,
Size_t& m, Size_t& n, Size_t& s1, Size_t& s2, Size_t& d, Size_t& K)
{
std::ifstream infoFile(filename);
if (!infoFile.is_open())
throw std::runtime_error("Cannot open info file.");

std::string tmp;
infoFile >> tmp >> matrixFile;
infoFile >> tmp >> q;
infoFile >> tmp >> m;
infoFile >> tmp >> n;
infoFile >> tmp >> s1;
infoFile >> tmp >> s2;
infoFile >> tmp >> d;
infoFile >> tmp >> K;
}

Loading