SHA256
prettify, add clangd for zed
This commit is contained in:
+9
-7
@@ -9,8 +9,8 @@
|
||||
#include <vector>
|
||||
#define CHACHE_LINE 64
|
||||
|
||||
//par - parallel
|
||||
//rr - round-robin
|
||||
// par - parallel
|
||||
// rr - round-robin
|
||||
|
||||
// Lab 1
|
||||
unsigned sum(const unsigned *V, std::size_t n) {
|
||||
@@ -54,7 +54,7 @@ unsigned sum_par_rr(const unsigned *V, std::size_t n) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
//just a different way of allocation. seems simialr in speed
|
||||
// just a different way of allocation. seems simialr in speed
|
||||
unsigned sum_par_rr_no_cache(const unsigned *V, std::size_t n) {
|
||||
unsigned acc = 0;
|
||||
unsigned *partial_sums =
|
||||
@@ -77,14 +77,16 @@ unsigned sum_par_rr_no_cache(const unsigned *V, std::size_t n) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
|
||||
// lab 3
|
||||
unsigned sum_loc_cpp(const unsigned *V, std::size_t n) {
|
||||
unsigned T = std::thread::hardware_concurrency();
|
||||
struct alignas(std::hardware_destructive_interference_size) p_t {//destructive as we want to minimize the distructive effect of cache interference
|
||||
struct alignas(std::hardware_destructive_interference_size)
|
||||
p_t { // destructive as we want to minimize the distructive effect of
|
||||
// cache interference
|
||||
unsigned v;
|
||||
};
|
||||
auto p = std::make_unique<p_t[]>(T);
|
||||
auto worker_proc = [V, n, T, &p](unsigned t) {
|
||||
auto worker_proc = [V, n, T, &p](const unsigned t) {
|
||||
size_t s = n / T, b = n % T;
|
||||
if (t < b)
|
||||
b = ++s * t;
|
||||
@@ -114,7 +116,7 @@ unsigned sum_loc_cpp(const unsigned *V, std::size_t n) {
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::size_t n = 1u << 29;
|
||||
std::size_t n = 1u << 28;
|
||||
auto data = std::make_unique<unsigned[]>(n);
|
||||
#pragma omp parallel for
|
||||
for (std::size_t i = 0; i < n; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user