add hashfunction for checksum calculation
This commit is contained in:
parent
2097c0fe36
commit
381fa26aac
@ -1,8 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
project(sycl_example)
|
||||
|
||||
find_package(AdaptiveCpp REQUIRED)
|
||||
|
||||
find_library(LIB_XXHASH xxhash)
|
||||
|
||||
add_executable(sycl_comp sycl_comp.cpp)
|
||||
add_sycl_to_target(TARGET sycl_comp)
|
||||
target_link_libraries(sycl_comp PRIVATE ${LIB_XXHASH})
|
||||
|
||||
11
matrix.hpp
11
matrix.hpp
@ -7,6 +7,8 @@
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
#include <xxhash.h>
|
||||
|
||||
template <class T> struct Matrix {
|
||||
std::uint32_t rows;
|
||||
std::uint32_t cols;
|
||||
@ -40,6 +42,10 @@ template <class T> struct Matrix {
|
||||
return data[row_i * cols + col_j];
|
||||
}
|
||||
|
||||
const T &operator()(std::uint32_t row_i, std::uint32_t col_j) const {
|
||||
return data[row_i * cols + col_j];
|
||||
}
|
||||
|
||||
Matrix<T> &operator=(const Matrix<T> &mat) {
|
||||
this->rows = mat.rows;
|
||||
this->cols = mat.cols;
|
||||
@ -58,7 +64,10 @@ template <class T> struct Matrix {
|
||||
return transposed;
|
||||
}
|
||||
|
||||
T sum() const { return std::accumulate(data.begin(), data.end(), 0); }
|
||||
XXH32_hash_t chksum() const {
|
||||
constexpr XXH32_hash_t HASH_SEED = 42;
|
||||
return XXH32(this->data.data(), data.size(), HASH_SEED);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> std::ostream &operator<<(std::ostream &os, Matrix<T> &mat) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user