cuElim/include/cuelim_m4rie.cuh

45 lines
1.1 KiB
Plaintext
Raw Normal View History

#ifndef INTERFACE_CUH
#define INTERFACE_CUH
#include "gf256/gf256_mul.cuh"
#include "gf256/gf256_elim.cuh"
#include <m4rie/m4rie.h>
namespace gf256
{
void mzedread(mzed_t *A, MatGF256 &mat)
{
assert(A->nrows == mat.nrows && A->ncols == mat.ncols);
for (size_t r = 0; r < A->nrows; r++)
{
for (size_t cn = 0; cn < A->x->width; cn++)
{
*mat.at_base(r, cn) = A->x->rows[r][cn];
}
}
}
void mzedwrite(MatGF256 &mat, mzed_t *A)
{
assert(A->nrows == mat.nrows && A->ncols == mat.ncols);
for (size_t r = 0; r < mat.nrows; r++)
{
for (size_t cn = 0; cn < mat.width; cn++)
{
A->x->rows[r][cn] = *mat.at_base(r, cn);
}
}
}
}
size_t gpu_mzed_elim(mzed_t *A)
{
gf256::MatGF256 mat(A->nrows, A->ncols);
gf256::mzedread(A, mat);
gf256::GF256 gf256(A->finite_field->minpoly);
gf256::ElimResult res = mat.gpu_elim(gf256);
gf256::mzedwrite(mat, A);
return res.rank;
}
#endif