This commit is contained in:
Christos Choutouridis 2020-12-05 23:49:54 +02:00
parent a93414b105
commit 377d37d512
6 changed files with 19 additions and 18 deletions

View File

@ -48,7 +48,7 @@ template<typename DataType, typename IndexType> struct SpMatRow;
template<typename DataType, typename IndexType> struct SpMatVal; template<typename DataType, typename IndexType> struct SpMatVal;
/*! /*!
* 2D-array wrapper for v1 and v2 part of the exercise t use as RAII * 2D-array wrapper for v1 and v2 part of the exercise used as RAII
* and copy-prevention. * and copy-prevention.
* *
* This is a very thin abstraction layer over a native array. * This is a very thin abstraction layer over a native array.
@ -180,7 +180,7 @@ Matrix<DataType, IndexType, Type> make_Matrix(IndexType s) {
* A(3, 4) = 7; * A(3, 4) = 7;
* \endcode * \endcode
* *
* We also provide getCol() and getRow() functions witch return a viwer/iterator to rows and * We also provide getCol() and getRow() functions witch return a viewer/iterator to rows and
* columns of the matrix. In the case of a symmetric matrix instead of a row we return the * columns of the matrix. In the case of a symmetric matrix instead of a row we return the
* equivalent column. This way we gain speed due to CSC format nature. * equivalent column. This way we gain speed due to CSC format nature.
* *
@ -290,15 +290,15 @@ struct SpMat {
} }
/*! /*!
* A read item functionality using binary search to find the correct row * A read item functionality using linear search to find the correct row
* *
* @param i The row number * @param i The row number
* @param j The column number * @param j The column number
* @return The value of the item or DataType{} if is not present. * @return The value of the item or DataType{} if is not present.
*/ */
DataType get2(IndexType i, IndexType j) { DataType get_lin(IndexType i, IndexType j) {
IndexType idx; bool found; IndexType idx; bool found;
std::tie(idx, found) =find2_idx(rows, col_ptr[j], col_ptr[j+1], i); std::tie(idx, found) =find_lin_idx(rows, col_ptr[j], col_ptr[j+1], i);
return (found) ? values[idx] : 0; return (found) ? values[idx] : 0;
} }
@ -318,7 +318,7 @@ struct SpMat {
*/ */
DataType set(DataType v, IndexType i, IndexType j) { DataType set(DataType v, IndexType i, IndexType j) {
IndexType idx; bool found; IndexType idx; bool found;
std::tie(idx, found) = find2_idx(rows, col_ptr[j], col_ptr[j+1], i); std::tie(idx, found) = find_lin_idx(rows, col_ptr[j], col_ptr[j+1], i);
if (found) if (found)
return values[idx] = v; // we don't change NNZ even if we write "0" return values[idx] = v; // we don't change NNZ even if we write "0"
else { else {
@ -405,7 +405,7 @@ private:
else e = m -1; else e = m -1;
} }
} }
return std::make_pair(end, false);; return std::make_pair(end, false);
} }
/*! /*!
* find helper for set using index for begin-end instead of iterators. * find helper for set using index for begin-end instead of iterators.
@ -418,7 +418,7 @@ private:
* \param end The vector's index to end * \param end The vector's index to end
* \param match What to search * \param match What to search
*/ */
std::pair<IndexType, bool> find2_idx(const std::vector<IndexType>& v, IndexType begin, IndexType end, IndexType match) { std::pair<IndexType, bool> find_lin_idx(const std::vector<IndexType>& v, IndexType begin, IndexType end, IndexType match) {
for ( ; begin < end ; ++begin) { for ( ; begin < end ; ++begin) {
if (match == v[begin]) return std::make_pair(begin, true); if (match == v[begin]) return std::make_pair(begin, true);
else if (match < v[begin]) return std::make_pair(begin, false); else if (match < v[begin]) return std::make_pair(begin, false);

View File

@ -223,10 +223,10 @@ private:
}; };
/*! /*!
* A Logger for entire programm. * A Logger for entire program.
*/ */
struct Log { struct Log {
struct Endl {} endl; //!< a tag objec to to use it as a new line request. struct Endl {} endl; //!< a tag object to to use it as a new line request.
//! We provide logging via << operator //! We provide logging via << operator
template<typename T> template<typename T>

View File

@ -86,6 +86,7 @@ uint32_t* vertexWiseTriangleCounts (uint32_t *coo_row, uint32_t *coo_col, uint32
// convert input // convert input
coo2csc_e (R, C, coo_row, coo_col, nz, n, 1); coo2csc_e (R, C, coo_row, coo_col, nz, n, 1);
// we use the lower triangular optimization just because ;)
for (uint32_t i=0 ; i<n ; ++i) { for (uint32_t i=0 ; i<n ; ++i) {
for (uint32_t j = C[i]; j<C[i+1] ; ++j) { for (uint32_t j = C[i]; j<C[i+1] ; ++j) {
uint32_t j_idx = R[j]; uint32_t j_idx = R[j];

View File

@ -127,7 +127,7 @@ bool get_options(int argc, char* argv[]){
// Input checkers // Input checkers
if (session.inputMatrix == InputMatrix::UNSPECIFIED) { if (session.inputMatrix == InputMatrix::UNSPECIFIED) {
std::cout << "Error message\n"; std::cout << "Invokation error. Try -h for details.\n";
status = false; status = false;
} }
#if CODE_VERSION == V4 #if CODE_VERSION == V4

View File

@ -138,7 +138,7 @@ int nworkers() {
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
*/ */
std::vector<value_t> triang_v(matrix& A) { std::vector<value_t> triang_v(matrix& A) {
std::vector<std::atomic<value_t>> c(A.size()); std::vector<std::atomic<value_t>> c(A.size());
@ -196,7 +196,7 @@ int nworkers() { return 1; }
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
*/ */
std::vector<value_t> triang_v(matrix& A) { std::vector<value_t> triang_v(matrix& A) {
std::vector<value_t> c(A.size()); std::vector<value_t> c(A.size());

View File

@ -45,7 +45,7 @@ int nworkers() {
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
* \warning * \warning
* The later(--triangular_only) produce correct results ONLY if we are after the total count. * The later(--triangular_only) produce correct results ONLY if we are after the total count.
*/ */
@ -128,7 +128,7 @@ int nworkers() {
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
* \warning * \warning
* The later(--triangular_only) produce correct results ONLY if we are after the total count. * The later(--triangular_only) produce correct results ONLY if we are after the total count.
*/ */
@ -199,7 +199,7 @@ int nworkers() {
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
* \warning * \warning
* The later(--triangular_only) produce correct results ONLY if we are after the total count. * The later(--triangular_only) produce correct results ONLY if we are after the total count.
*/ */
@ -297,7 +297,7 @@ int nworkers() { return 1; }
* \note * \note
* We use two methods of calculation based on \c --make_symmetric or \c --triangular_only * We use two methods of calculation based on \c --make_symmetric or \c --triangular_only
* - A full matrix calculation which update only c[i] * - A full matrix calculation which update only c[i]
* - A lower triangular matrix which update c[i], c[j], c[k]. This is wayyy faster. * - A lower triangular matrix which update c[i], c[j], c[k]. This is waaayyy faster.
* \warning * \warning
* The later(--triangular_only) produce correct results ONLY if we are after the total count. * The later(--triangular_only) produce correct results ONLY if we are after the total count.
*/ */