#pragma once #include "pch.h" #pragma strict_gs_...
Creato il: 23 agosto 2025
Risposto usando GPT-5 Thinking da Chat01
Creato il: 23 agosto 2025
Risposto usando GPT-5 Thinking da Chat01
#pragma once
#include "pch.h"
#pragma strict_gs_check(push, off)
#pragma optimize(on)
#pragma inline_recursion(on)
#pragma inline_depth(255u)
#pragma runtime_checks("", off)
#pragma check_stack(off)
#pragma fenv_access(off)
#pragma auto_inline(on)
#pragma managed(push, off)
static __declspec(noalias) __forceinline float xor_rand_grsh(uint32_t& __restrict state) noexcept
{
uint32_t s = state;
s ^= s << 13u;
s ^= s >> 17u;
s ^= s << 5u;
state = s;
return fmaf(s, 0x1.0p-31f, -1.0f);
}
static __declspec(noalias) __forceinline float xor_rand(uint32_t& __restrict state) noexcept
{
uint32_t s = state;
s ^= s << 13u;
s ^= s >> 17u;
s ^= s << 5u;
state = s;
return s * 0x1.0p-32f;
}
static __declspec(noalias) __forceinline float HillFunc(const float x, uint32_t seed) noexcept
{
int32_t i = 0;
__declspec(align(64u)) float angles[14u];
const float start_angle = 6.28318530717958647692f * x;
#pragma loop(ivdep)
while (i < 14) {
angles[i] = start_angle * (i + 1);
++i;
}
text__declspec(align(64u)) float sin_vals[14u]; __declspec(align(64u)) float cos_vals[14u]; fabe13_sincos_scalar_simple(angles, sin_vals, cos_vals, 14u); float res = fmaf(xor_rand(seed), 2.0f, -1.1f); --i; while (i >= 0) { res += fmaf(fmaf(xor_rand(seed), 2.0f, -1.1f), sin_vals[i], fmaf(xor_rand(seed), 2.0f, -1.1f) * cos_vals[i]); --i; } return res;
}
static __declspec(noalias) __forceinline float ShekelFunc(const float x, uint32_t seed) noexcept
{
uint32_t i = 0u;
float res = 0.0f;
textwhile (i < 10u) { const float r = xor_rand(seed); const float x_part = fmaf(-r, 10.0f, x); res -= 1.0f / fmaf(fmaf(xor_rand(seed), 20.0f, 0.5f), x_part * x_part, fmaf(xor_rand(seed), 0.4f, 1.0f)); ++i; } return res;
}
static __declspec(noalias) __forceinline float GrishaginFunc(const float x1, const float x2, uint32_t seed) noexcept
{
int32_t i = 0;
__declspec(align(64u)) float angles_i[8u];
__declspec(align(64u)) float angles_j[8u];
#pragma loop(ivdep)
while (i < 8) {
const float pi_mult = 3.14159265358979323846f * (i + 1);
angles_i[i] = pi_mult * x1;
angles_j[i] = pi_mult * x2;
++i;
}
text__declspec(align(64u)) float sin_i[8u], cos_i[8u]; __declspec(align(64u)) float sin_j[8u], cos_j[8u]; fabe13_sincos_scalar_simple(angles_i, sin_i, cos_i, 8u); fabe13_sincos_scalar_simple(angles_j, sin_j, cos_j, 8u); --i; float part1 = 0.0f; float part2 = 0.0f; while (i >= 0) { uint32_t j = 0u; while (j < 8u) { const float sin_term = sin_i[i] * sin_i[i]; const float cos_term = cos_j[j] * cos_j[j]; part1 = fmaf(xor_rand_grsh(seed), sin_term, fmaf(xor_rand_grsh(seed), cos_term, part1)); part2 = fmaf(-xor_rand_grsh(seed), cos_term, fmaf(xor_rand_grsh(seed), sin_term, part2)); ++j; } --i; } return -sqrtf(fmaf(part1, part1, part2 * part2));
}
static __declspec(noalias) __forceinline float RastriginFunc(const float x1, const float x2) noexcept
{
const float term1 = fmaf(x1, x1, x2 * x2);
return (term1 - fmaf(
fabe13_cos(6.28318530717958647692f * x1) +
fabe13_cos(6.28318530717958647692f * x2),
10.0f,
-14.6f)) *
fmaf(-term1, 0.25f, 18.42f);
}
static __declspec(noalias) __forceinline float Shag(const float _m, const float x1, const float x2, const float y1,
const float y2, const uint32_t _N, const float _r) noexcept
{
const float diff = y2 - y1;
return _N == 1u
? fmaf(-(1.0f / _m), diff, x1 + x2) * 0.5f
: diff > 0u
? fmaf(-(1.0f / (_m * _m)), (diff) * (diff)_r, x1 + x2) * 0.5f
: fmaf(1.0f / (_m * _m), (diff) * (diff)_r, x1 + x2) * 0.5f;
}
const __declspec(align(32u)) struct Interval final
{
public:
std::pair<float, float> start;
std::pair<float, float> end;
float M;
float R;
text__declspec(noalias) __forceinline Interval(const std::pair<float, float>& __restrict _start, const std::pair<float, float>& __restrict _end, const uint32_t _N) noexcept : start(_start) , end(_end) , M(_N == 1u ? fabsf(_end.second - _start.second) / (_end.first - _start.first) : _N == 2u ? fabsf(_end.second - _start.second) / sqrtf(_end.first - _start.first) : fabsf(_end.second - _start.second) / powf(_end.first - _start.first, 1.0f / float(_N))) { } const __declspec(noalias) __forceinline void ChangeCharacteristic(const float _m, const uint32_t _N) noexcept { const float delta_x = end.first - start.first; const float delta_y = end.second - start.second; switch (_N) { case 1u: R = fmaf( -(end.second + start.second), 2.0f, fmaf(_m, delta_x, (delta_y * delta_y) / (_m * delta_x))); break; case 2u: { const float sqrt_dx = sqrtf(delta_x); R = fmaf( -(end.second + start.second), 2.0f, fmaf(_m, sqrt_dx, (delta_y * delta_y) / (_m * sqrt_dx))); } break; default: { const float pow_dx = powf(delta_x, 1.0f / _N); R = fmaf( -(end.second + start.second), 2.0f, fmaf(_m, pow_dx, (delta_y * delta_y) / (_m * pow_dx))); } } }
};
static __declspec(noalias) __forceinline bool Compare(const Interval& __restrict a, const Interval& __restrict b) noexcept
{
return a.R < b.R;
}
const __declspec(noalias) __forceinline PeanoCurve_2D* PeanoCurve_2D::HitTest_2D(float x) const noexcept
{
uint32_t i = 0u;
const uint32_t _razvertka = this->razvertka;
uint32_t num;
const float this_a = this->a;
x -= this_a;
const float b_minus_a = this->b - this_a;
const float inv_b_minus_a = 1.0f / b_minus_a;
const PeanoCurve_2D* Curr = this;
textwhile (i != _razvertka) { const uint32_t shift = 1u << ++i + i; num = shift * x * inv_b_minus_a; x = fmaf(-ldexp(1.0f, -(i << 1)) * num, b_minus_a, x); const List currType = Curr->Type; switch (num) { case 0u: Curr = (currType == Top || currType == Right) ? Curr->DownLeft.get() : Curr->TopRight.get(); break; case 1u: Curr = (currType == Top || currType == Left) ? Curr->TopLeft.get() : Curr->DownRight.get(); break; case 2u: Curr = (currType == Top || currType == Right) ? Curr->TopRight.get() : Curr->DownLeft.get(); break; case 3u: Curr = (currType == Top || currType == Left) ? Curr->DownRight.get() : Curr->TopLeft.get(); } } return Curr;
}
const __declspec(noalias) __forceinline float PeanoCurve_2D::FindX_2D(float target_x1, float target_x2) const noexcept
{
uint32_t _razvertka = this->razvertka;
uint32_t _razvertka1 = _razvertka;
float x1, x2, x = this->a;
const float b_minus_a = this->b - x;
const PeanoCurve_2D* Curr = this;
textwhile (_razvertka != 0u) { const uint32_t exponent = _razvertka1 - _razvertka-- << 1u; x1 = Curr->x1; x2 = Curr->x2; const List currType = Curr->Type; if (target_x1 > x1 && target_x2 > x2) { Curr = Curr->TopRight.get(); if (currType == Top || currType == Right) { x = fmaf(ldexp(1.0f, -exponent) * 0.5f, b_minus_a, x); } } else if (target_x1 < x1 && target_x2 > x2) { Curr = Curr->TopLeft.get(); if (currType == Top || currType == Left) { x = fmaf(ldexp(1.0f, -exponent) * 0.25f, b_minus_a, x); } else { x = fmaf(ldexp(1.0f, -exponent) * 0.75f, b_minus_a, x); } } else if (target_x1 < x1 && target_x2 < x2) { Curr = Curr->DownLeft.get(); if (currType == Down || currType == Left) { x = fmaf(ldexp(1.0f, -exponent) * 0.5f, b_minus_a, x); } } else { Curr = Curr->DownRight.get(); if (currType == Top || currType == Left) { x = fmaf(ldexp(1.0f, -exponent) * 0.75f, b_minus_a, x); } else { x = fmaf(ldexp(1.0f, -exponent) * 0.25f, b_minus_a, x); } } } return x;
}
extern const boost::mpi::communicator world;
extern std::unique_ptr<PeanoCurve_2D> Curve;
extern std::unique_ptr<PeanoCurve_2D> Curve_Inverted;
__declspec(dllexport) __declspec(noalias) std::vector<float> Base_LNA_1_2_Mer_AGP(const uint32_t N,
const uint32_t global_iterations, const float a, const float b, const float c, const float d, const uint32_t r,
const bool mode, const float epsilon, const uint32_t seed) noexcept
{
if (N == 1u) {
const float initial_length = b - a;
float dmax = initial_length;
textstd::vector<float> Extr; Extr.reserve((global_iterations << 1u) + 2u); std::vector<Interval> R; R.reserve(global_iterations + 1u); float best_f = ShekelFunc(a, seed); const float end_val = ShekelFunc(b, seed); uint32_t schetchick = 0u; std::pair<float, float> x_Rmax = std::make_pair(a, b); std::pair<float, float> y_Rmax = std::make_pair(best_f, end_val); R.emplace_back(std::make_pair(a, best_f), std::make_pair(b, end_val), N); float Mmax = R.front().M; float m = r * Mmax; while (true) { if (++schetchick == global_iterations) { const Interval& front = R.front(); Extr.emplace_back(front.end.first - front.start.first); Extr.emplace_back(global_iterations); return Extr; } const float x1 = x_Rmax.first; const float x2 = x_Rmax.second; const float y1 = y_Rmax.first; const float y2 = y_Rmax.second; const float new_point = Shag(m, x1, x2, y1, y2, N, r); const float new_value = ShekelFunc(new_point, seed); const std::pair<float, float> promejutochnaya_tochka = std::make_pair(new_point, new_value); if (new_value < best_f) { best_f = new_value; Extr.emplace_back(best_f); Extr.emplace_back(new_point); } std::pop_heap(R.begin(), R.end(), Compare); const Interval promejutochny_otrezok = std::move(R.back()); R.pop_back(); Interval curr(promejutochny_otrezok.start, promejutochnaya_tochka, N); Interval curr1(promejutochnaya_tochka, promejutochny_otrezok.end, N); const float currM = curr.M > curr1.M ? curr.M : curr1.M; const float len2 = promejutochny_otrezok.end.first - new_point; const float len1 = new_point - promejutochny_otrezok.start.first; const size_t r_size = R.size(); if (len2 + len1 == dmax) { dmax = len2 > len1 ? len2 : len1;
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float len = R[i].end.first - R[i].start.first;
if (len > dmax) {
dmax = len;
}
}
}
textif (mode) { const float threshold_03 = 0.3f * initial_length; if (threshold_03 > dmax && schetchick % 3u == 0u || 10.0f * dmax < initial_length) { if (currM > Mmax) { Mmax = currM; m = r * Mmax; } const float inv_threshold_03 = 1.0f / threshold_03; const float progress = fmaf(-inv_threshold_03, dmax, 1.0f); const float alpha = fmaf(progress, progress, 1.0f); const float betta = 2.0f - alpha; const float inv_dmax = 1.0f / dmax; const float MULTIPLIER = inv_dmax * Mmax; const float global_coeff = fmaf(MULTIPLIER, r, -MULTIPLIER); const float GLOBAL_FACTOR = betta * global_coeff; curr.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len1, curr.M * alpha), N); curr1.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len2, curr1.M * alpha), N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float len_item = R[i].end.first - R[i].start.first;
R[i].ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len_item, R[i].M * alpha), N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
if (currM > Mmax) {
Mmax = currM;
m = r * Mmax;
curr.ChangeCharacteristic(m, N);
curr1.ChangeCharacteristic(m, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R[i].ChangeCharacteristic(m, N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
curr.ChangeCharacteristic(m, N);
curr1.ChangeCharacteristic(m, N);
}
}
} else {
if (currM > Mmax) {
Mmax = currM;
m = r * Mmax;
curr.ChangeCharacteristic(m, N);
curr1.ChangeCharacteristic(m, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R[i].ChangeCharacteristic(m, N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
curr.ChangeCharacteristic(m, N);
curr1.ChangeCharacteristic(m, N);
}
}
textR.emplace_back(std::move(curr)); std::push_heap(R.begin(), R.end(), Compare); R.emplace_back(std::move(curr1)); std::push_heap(R.begin(), R.end(), Compare); const Interval& top = R.front(); const float interval_length = top.end.first - top.start.first; if (interval_length < epsilon) { Extr.emplace_back(interval_length); Extr.emplace_back(schetchick); return Extr; } x_Rmax = std::make_pair(top.start.first, top.end.first); y_Rmax = std::make_pair(top.start.second, top.end.second); } } else { std::vector<float> Extr; Extr.reserve(3u * global_iterations + 2u); std::vector<Interval> R; R.reserve(global_iterations + 1u); std::vector<Interval> R_Inverted; R_Inverted.reserve(global_iterations + 1u); const float divider = 1u << (2u * Curve_Inverted->razvertka + 1u); const float x_addition = (b - a) / divider; const float y_addition = (d - c) / divider; const float true_start = a + x_addition; const float true_end = b - x_addition; const float initial_length = true_end - true_start; float dmax = initial_length; float dmax_Inverted = initial_length; uint32_t schetchick = 0u; const std::pair<float, float> start = std::make_pair(true_start, RastriginFunc(true_start, c + y_addition)); const std::pair<float, float> end = std::make_pair(true_end, RastriginFunc(true_end, c + y_addition)); const std::pair<float, float> start_Inverted = std::make_pair(true_start, RastriginFunc(true_end, d - y_addition)); const std::pair<float, float> end_Inverted = std::make_pair(true_end, RastriginFunc(true_start, d - y_addition)); std::pair<float, float> x_Rmax = std::make_pair(start.first, end.first); std::pair<float, float> y_Rmax = std::make_pair(start.second, end.second); std::pair<float, float> x_Rmax_Inverted = std::make_pair(start_Inverted.first, end_Inverted.first); std::pair<float, float> y_Rmax_Inverted = std::make_pair(start_Inverted.second, end_Inverted.second); float best_f = end_Inverted.second; Interval initial_interval(start, end, N); Interval initial_interval_Inverted(start_Inverted, end_Inverted, N); float Mmax = initial_interval.M; float Mmax_Inverted = initial_interval_Inverted.M; float m = r * Mmax; float m_Inverted = r * Mmax_Inverted; R.emplace_back(std::move(initial_interval)); R_Inverted.emplace_back(std::move(initial_interval_Inverted)); while (true) { if (++schetchick == global_iterations) { const Interval& topA = R.front(); const Interval& topB = R_Inverted.front(); const float lenA = topA.end.first - topA.start.first; const float lenB = topB.end.first - topB.start.first; const float interval_length = lenA > lenB ? lenA : lenB; Extr.emplace_back(interval_length); Extr.emplace_back(global_iterations); return Extr; } const float x1A = x_Rmax.first; const float x2A = x_Rmax.second; const float y1A = y_Rmax.first; const float y2A = y_Rmax.second; const float x1B = x_Rmax_Inverted.first; const float x2B = x_Rmax_Inverted.second; const float y1B = y_Rmax_Inverted.first; const float y2B = y_Rmax_Inverted.second; const float new_param_A = Shag(m, x1A, x2A, y1A, y2A, N, r); const float new_param_B = Shag(m_Inverted, x1B, x2B, y1B, y2B, N, r); const float cooling = expf(-schetchick / 200.0f); const uint32_t T = fmaf(20.0f, cooling, 10.0f); const float k = fmaf(0.2f, cooling, 0.7f); const PeanoCurve_2D* pA = Curve->HitTest_2D(new_param_A); const PeanoCurve_2D* pB = Curve_Inverted->HitTest_2D(new_param_B); if (schetchick % T == 0u && schetchick > T && !R.empty() && !R_Inverted.empty()) { const Interval& topA = R.front(); const Interval& topB = R_Inverted.front(); const PeanoCurve_2D* p1A = Curve->HitTest_2D(topA.start.first); const PeanoCurve_2D* p2A = Curve->HitTest_2D(topA.end.first); const PeanoCurve_2D* p1B = Curve_Inverted->HitTest_2D(topB.start.first); const PeanoCurve_2D* p2B = Curve_Inverted->HitTest_2D(topB.end.first); const float newParam1_B = Curve->FindX_2D(p1B->x1, p1B->x2); const float newParam2_B = Curve->FindX_2D(p2B->x1, p2B->x2); const float newParam1_A = Curve_Inverted->FindX_2D(p1A->x1, p1A->x2); const float newParam2_A = Curve_Inverted->FindX_2D(p2A->x1, p2A->x2); const std::pair<float, float> newStart_A(newParam1_A, topA.start.second); const std::pair<float, float> newEnd_A(newParam2_A, topA.end.second); const std::pair<float, float> newStart_B(newParam1_B, topB.start.second); const std::pair<float, float> newEnd_B(newParam2_B, topB.end.second); Interval injected_A(newStart_A, newEnd_A, N); Interval injected_B(newStart_B, newEnd_B, N); injected_A.R = topA.R * k; injected_B.R = topB.R * k; R.emplace_back(std::move(injected_B)); std::push_heap(R.begin(), R.end(), Compare); R_Inverted.emplace_back(std::move(injected_A)); std::push_heap(R_Inverted.begin(), R_Inverted.end(), Compare); } const float new_x1_A = pA->x1; const float new_x2_A = pA->x2; const float new_x1_B = pB->x1; const float new_x2_B = pB->x2; const float new_value_A = RastriginFunc(new_x1_A, new_x2_A); const float new_value_B = RastriginFunc(new_x1_B, new_x2_B); const std::pair<float, float> promejutochnaya_tochka_A = std::make_pair(new_param_A, new_value_A); const std::pair<float, float> promejutochnaya_tochka_B = std::make_pair(new_param_B, new_value_B); if (new_value_A < best_f) { best_f = new_value_A; if (new_value_B < best_f) { best_f = new_value_B; Extr.emplace_back(best_f); Extr.emplace_back(new_x1_B); Extr.emplace_back(new_x2_B); } else { Extr.emplace_back(best_f); Extr.emplace_back(new_x1_A); Extr.emplace_back(new_x2_A); } } else if (new_value_B < best_f) { best_f = new_value_B; Extr.emplace_back(best_f); Extr.emplace_back(new_x1_B); Extr.emplace_back(new_x2_B); } std::pop_heap(R.begin(), R.end(), Compare); const Interval promejutochny_otrezok_A = std::move(R.back()); R.pop_back(); std::pop_heap(R_Inverted.begin(), R_Inverted.end(), Compare); const Interval promejutochny_otrezok_B = std::move(R_Inverted.back()); R_Inverted.pop_back(); Interval curr_A(promejutochny_otrezok_A.start, promejutochnaya_tochka_A, N); Interval curr1_A(promejutochnaya_tochka_A, promejutochny_otrezok_A.end, N); Interval curr_B(promejutochny_otrezok_B.start, promejutochnaya_tochka_B, N); Interval curr1_B(promejutochnaya_tochka_B, promejutochny_otrezok_B.end, N); const float currM_A = curr1_A.M > curr_A.M ? curr1_A.M : curr_A.M; const float currM_B = curr1_B.M > curr_B.M ? curr1_B.M : curr_B.M; const float len2_A = promejutochny_otrezok_A.end.first - new_param_A; const float len1_A = new_param_A - promejutochny_otrezok_A.start.first; const float len2_B = promejutochny_otrezok_B.end.first - new_param_B; const float len1_B = new_param_B - promejutochny_otrezok_B.start.first; const size_t r_size = R.size(); if (len2_A + len1_A == dmax) { dmax = len2_A > len1_A ? len2_A : len1_A;
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float l = R[i].end.first - R[i].start.first;
if (l > dmax) {
dmax = l;
}
}
}
if (len2_B + len1_B == dmax_Inverted) {
dmax_Inverted = len2_B > len1_B ? len2_B : len1_B;
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float l = R_Inverted[i].end.first - R_Inverted[i].start.first;
if (l > dmax_Inverted) {
dmax_Inverted = l;
}
}
}
textif (mode) { const float threshold_03 = 0.3f * initial_length; if (threshold_03 > dmax && schetchick % 3u == 0u || 10.0f * dmax < initial_length) { if (currM_A > Mmax) { Mmax = currM_A; m = r * Mmax; } const float inv_threshold_03 = 1.0f / threshold_03; const float progress = fmaf(-inv_threshold_03, dmax, 1.0f); const float alpha = fmaf(progress, progress, 1.0f); const float betta = 2.0f - alpha; const float inv_dmax = 1.0f / dmax; const float MULTIPLIER = inv_dmax * Mmax; const float global_coeff = fmaf(MULTIPLIER, r, -MULTIPLIER); const float GLOBAL_FACTOR = betta * global_coeff; curr_A.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len1_A, curr_A.M * alpha), N); curr1_A.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len2_A, curr1_A.M * alpha), N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float li = R[i].end.first - R[i].start.first;
R[i].ChangeCharacteristic(fmaf(GLOBAL_FACTOR, li, R[i].M * alpha), N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
if (currM_A > Mmax) {
Mmax = currM_A;
m = r * Mmax;
curr_A.ChangeCharacteristic(m, N);
curr1_A.ChangeCharacteristic(m, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R[i].ChangeCharacteristic(m, N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
curr_A.ChangeCharacteristic(m, N);
curr1_A.ChangeCharacteristic(m, N);
}
}
textif (threshold_03 > dmax_Inverted && schetchick % 3u == 0u || 10.0f * dmax_Inverted < initial_length) { if (currM_B > Mmax_Inverted) { Mmax_Inverted = currM_B; m_Inverted = r * Mmax_Inverted; } const float inv_threshold_03 = 1.0f / threshold_03; const float progress = fmaf(-inv_threshold_03, dmax_Inverted, 1.0f); const float alpha = fmaf(progress, progress, 1.0f); const float betta = 2.0f - alpha; const float inv_dmax = 1.0f / dmax_Inverted; const float MULTIPLIER = inv_dmax * Mmax_Inverted; const float global_coeff = fmaf(MULTIPLIER, r, -MULTIPLIER); const float GLOBAL_FACTOR = betta * global_coeff; curr_B.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len1_B, curr_B.M * alpha), N); curr1_B.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len2_B, curr1_B.M * alpha), N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
const float li = R_Inverted[i].end.first - R_Inverted[i].start.first;
R_Inverted[i].ChangeCharacteristic(fmaf(GLOBAL_FACTOR, li, R_Inverted[i].M * alpha), N);
}
std::make_heap(R_Inverted.begin(), R_Inverted.end(), Compare);
} else {
if (currM_B > Mmax_Inverted) {
Mmax_Inverted = currM_B;
m_Inverted = r * Mmax_Inverted;
curr_B.ChangeCharacteristic(m_Inverted, N);
curr1_B.ChangeCharacteristic(m_Inverted, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R_Inverted[i].ChangeCharacteristic(m_Inverted, N);
}
std::make_heap(R_Inverted.begin(), R_Inverted.end(), Compare);
} else {
curr_B.ChangeCharacteristic(m_Inverted, N);
curr1_B.ChangeCharacteristic(m_Inverted, N);
}
}
} else {
if (currM_A > Mmax) {
Mmax = currM_A;
m = r * Mmax;
curr_A.ChangeCharacteristic(m, N);
curr1_A.ChangeCharacteristic(m, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R[i].ChangeCharacteristic(m, N);
}
std::make_heap(R.begin(), R.end(), Compare);
} else {
curr_A.ChangeCharacteristic(m, N);
curr1_A.ChangeCharacteristic(m, N);
}
textif (currM_B > Mmax_Inverted) { Mmax_Inverted = currM_B; m_Inverted = r * Mmax_Inverted; curr_B.ChangeCharacteristic(m_Inverted, N); curr1_B.ChangeCharacteristic(m_Inverted, N);
#pragma loop(ivdep)
for (size_t i = 0u; i < r_size; ++i) {
R_Inverted[i].ChangeCharacteristic(m_Inverted, N);
}
std::make_heap(R_Inverted.begin(), R_Inverted.end(), Compare);
} else {
curr_B.ChangeCharacteristic(m_Inverted, N);
curr1_B.ChangeCharacteristic(m_Inverted, N);
}
}
textR.emplace_back(std::move(curr_A)); std::push_heap(R.begin(), R.end(), Compare); R.emplace_back(std::move(curr1_A)); std::push_heap(R.begin(), R.end(), Compare); R_Inverted.emplace_back(std::move(curr_B)); std::push_heap(R_Inverted.begin(), R_Inverted.end(), Compare); R_Inverted.emplace_back(std::move(curr1_B)); std::push_heap(R_Inverted.begin(), R_Inverted.end(), Compare); const Interval& topA = R.front(); const Interval& topB = R_Inverted.front(); const float interval_length_A = topA.end.first - topA.start.first; const float interval_length_B = topB.end.first - topB.start.first; const float interval_length = interval_length_A > interval_length_B ? interval_length_A : interval_length_B; if (interval_length < epsilon) { Extr.emplace_back(interval_length); Extr.emplace_back(schetchick); return Extr; } x_Rmax = std::make_pair(topA.start.first, topA.end.first); y_Rmax = std::make_pair(topA.start.second, topA.end.second); x_Rmax_Inverted = std::make_pair(topB.start.first, topB.end.first); y_Rmax_Inverted = std::make_pair(topB.start.second, topB.end.second); } }
} ΡΠ°ΡΡΠΌΠΎΡΡΠΈ Π·Π΄Π΅ΡΡ Π²ΡΠΎΡΡΡ Π²Π΅ΡΠ²Ρ Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° - Π΅Ρ Π½ΡΠΆΠ½ΠΎ ΡΠ°ΡΠΏΠ°ΡΠ°Π»Π»Π΅Π»ΠΈΡΡ ΡΠ΅ΡΠ΅Π· boost::mpi ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, Π²ΡΡ ΡΡΠΎ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ Π½Π° ΠΎΠ±ΡΡΠ½ΠΎΠΉ ΡΠ°Π·Π²ΡΡΡΠΊΠ΅ - Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π½Π° ΠΏΡΠΎΡΠ΅ΡΡΠ΅ Ρ ΡΠ°Π½Π³ΠΎΠΌ 0, Π²ΡΡ ΡΡΠΎ Π½Π° ΠΏΠ΅ΡΠ΅Π²ΡΡΠ½ΡΡΠΎΠΉ ΡΠ°Π·Π²ΡΡΡΠΊΠ΅ Π½Π° ΠΏΡΠΎΡΠ΅ΡΡΠ΅ Ρ ΡΠ°Π½Π³ΠΎΠΌ 1, Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ, ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»ΠΎΠ², ΡΠΈΠΊΠ»Ρ, ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊ ΠΈ Ρ Π΄ - Π²ΡΠ΅ ΡΡΠΈ Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡΡ ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ ΠΈΠ·ΠΎΠ»ΠΈΡΠΎΠ²Π°Π½Π½ΠΎ Π½Π΅Π·Π°Π²ΠΈΡΠΈΠΌΠΎ, ΡΠ°Π·Π²ΡΡΡΠΊΠΈ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠΎΠΎΠ±ΡΠ°ΡΡΡΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠΎΠ±ΠΎΠΉ Π² ΠΌΠΎΠΌΠ΅Π½Ρ ΠΊΡΠΎΡΡ ΠΈΠ½ΡΠ΅ΠΊΡΠΈΠΉ Π² ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΠΈΠΈ Ρ ΠΏΡΠ°Π²ΠΈΠ»ΠΎΠΌ ΠΊΠΎΠ³Π΄Π° ΡΡΠΈ ΠΊΡΠΎΡΡ ΠΈΠ½ΡΠ΅ΠΊΡΠΈΠΈ Π΄ΠΎΠ»ΠΆΠ½Ρ Π½Π°ΡΡΡΠΏΠ°ΡΡ, Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ Π΅ΡΡ ΡΠ°Π·Π²ΡΡΡΠΊΠΈ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠΎΠΎΠ±ΡΠ°ΡΡΡΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠΎΠ±ΠΎΠΉ Π² ΠΌΠΎΠΌΠ΅Π½Ρ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΡ Π»ΡΡΡΠ΅ΠΉ ΡΠΎΡΠΊΠΈ - Ρ ΠΎΡΡ ΡΡΠΎ ΠΏΠΎΠ΄ Π²ΠΎΠΏΡΠΎΡΠΎΠΌ, ΡΠ°ΠΊ ΠΊΠ°ΠΊ ΡΡΠΎ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΡΠ»ΠΈΡΠΊΠΎΠΌ Π΄ΠΎΡΠΎΠ³ΠΎ, ΠΏΡΠ°Π²ΠΈΠ»ΠΎ ΠΎΡΡΠ°Π½ΠΎΠ²Π° ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΡΠ°ΠΊΠΈΠΌ - ΡΡΡΡ ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ ΠΊΠΎΠ³Π΄Π° ΠΎΡΡΠ°Π½ΠΎΠ²ΠΈΠ»Π° ΡΡΡΡ ΠΎΠ΄Π½Π° ΠΈΠ· ΡΠ°Π·Π²ΡΡΡΠΎΠΊ Π½Π° ΠΎΠ΄Π½ΠΎΠΌ ΠΈΠ· ΠΏΡΠΎΡΠ΅ΡΡΠΎΠ², ΡΠ°ΠΌ MPI ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ Ρ ΠΌΠ΅Π½Ρ Π·Π°Π΄Π°ΡΡΡΡ Π²ΠΎ Π²ΡΠ΅ΠΌΡ Π·Π°Π³ΡΡΠ·ΠΊΠΈ ΡΡΠΎΠΉ DLL Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ ΡΠ°ΠΊ: #include "pch.h"
const boost::mpi::environment mpi_env;
const boost::mpi::communicator world;
std::unique_ptr<PeanoCurve_2D> Curve;
std::unique_ptr<PeanoCurve_2D> Curve_Inverted;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
const int32_t rank = world.rank();
if (rank == 0) {
Curve = std::make_unique<PeanoCurve_2D>(List::Top, 12, -2.2f, 1.8f, -2.2f, 1.8f);
}
else if (rank == 1) {
Curve_Inverted = std::make_unique<PeanoCurve_2D>(List::Down, 12, -2.2f, 1.8f, -2.2f, 1.8f);
}
}
return TRUE;
}, ΡΠ°ΠΌΠΎ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ Π΄Π΅ΡΠ΅Π²ΡΠ΅Π² ΠΎΡΡΠ°Π²Ρ Π² ΠΌΠΎΠΌΠ΅Π½ΡΠ΅ Π·Π°Π³ΡΡΠ·ΠΊΠΈ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ ΠΎΠ½ΠΎ ΡΠ°ΠΌ ΠΈ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΏΡΠΎΠΈΡΡ
ΠΎΠ΄ΠΈΡΡ ΠΎΠ΄ΠΈΠ½ ΡΠ°Π·, ΡΠ°ΠΌΠΎ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΠ΅ Π΄Π΅ΡΠ΅Π²ΡΠ΅Π² Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ ΠΏΠ°ΡΠ°Π»Π»Π΅Π»ΡΠ½ΠΎ ΡΠ΅ΡΠ΅Π· TBB: #pragma once
#include <cstdint>
#include <memory>
#include <oneapi/tbb/parallel_invoke.h>
const enum List : uint8_t {
Top = 0b00,
Down = 0b01,
Left = 0b10,
Right = 0b11
};
const __declspec(align(64u)) struct PeanoCurve_2D final {
public:
const List Type;
const uint32_t razvertka;
const float a;
const float b;
const float c;
const float d;
const float x1;
const float x2;
std::unique_ptr<PeanoCurve_2D> DownLeft;
std::unique_ptr<PeanoCurve_2D> TopLeft;
std::unique_ptr<PeanoCurve_2D> TopRight;
std::unique_ptr<PeanoCurve_2D> DownRight;
text__declspec(noalias) __forceinline PeanoCurve_2D( const List _Type, uint32_t _razvertka, const float _a, const float _b, const float _c, const float _d) noexcept : Type(_Type), razvertka(_razvertka), a(_a), b(_b), c(_c), d(_d), x1(fmaf(0.5f, _a, 0.5f * _b)), x2(fmaf(0.5f, _c, 0.5f * _d)) { if (_razvertka-- != 0u) { if (_razvertka > 8u) { switch (_Type) { case Top: tbb::parallel_invoke( [&]() { DownLeft = std::make_unique<PeanoCurve_2D>(Right, _razvertka, _a, x1, _c, x2); }, [&]() { TopLeft = std::make_unique<PeanoCurve_2D>(Top, _razvertka, _a, x1, x2, _d); }, [&]() { TopRight = std::make_unique<PeanoCurve_2D>(Top, _razvertka, x1, _b, x2, _d); }, [&]() { DownRight = std::make_unique<PeanoCurve_2D>(Left, _razvertka, x1, _b, _c, x2); } ); break; case Down: tbb::parallel_invoke( [&]() { TopRight = std::make_unique<PeanoCurve_2D>(Left, _razvertka, x1, _b, x2, _d); }, [&]() { DownRight = std::make_unique<PeanoCurve_2D>(Down, _razvertka, x1, _b, _c, x2); }, [&]() { DownLeft = std::make_unique<PeanoCurve_2D>(Down, _razvertka, _a, x1, _c, x2); }, [&]() { TopLeft = std::make_unique<PeanoCurve_2D>(Right, _razvertka, _a, x1, x2, _d); } ); break; case Right: tbb::parallel_invoke( [&]() { DownLeft = std::make_unique<PeanoCurve_2D>(Top, _razvertka, _a, x1, _c, x2); }, [&]() { DownRight = std::make_unique<PeanoCurve_2D>(Right, _razvertka, x1, _b, _c, x2); }, [&]() { TopRight = std::make_unique<PeanoCurve_2D>(Right, _razvertka, x1, _b, x2, _d); }, [&]() { TopLeft = std::make_unique<PeanoCurve_2D>(Down, _razvertka, _a, x1, x2, _d); } ); break; case Left: tbb::parallel_invoke( [&]() { TopRight = std::make_unique<PeanoCurve_2D>(Down, _razvertka, x1, _b, x2, _d); }, [&]() { TopLeft = std::make_unique<PeanoCurve_2D>(Left, _razvertka, _a, x1, x2, _d); }, [&]() { DownLeft = std::make_unique<PeanoCurve_2D>(Left, _razvertka, _a, x1, _c, x2); }, [&]() { DownRight = std::make_unique<PeanoCurve_2D>(Top, _razvertka, x1, _b, _c, x2); } ); } } else { switch (_Type) { case Top: DownLeft = std::make_unique<PeanoCurve_2D>(Right, _razvertka, _a, x1, _c, x2); TopLeft = std::make_unique<PeanoCurve_2D>(Top, _razvertka, _a, x1, x2, _d); TopRight = std::make_unique<PeanoCurve_2D>(Top, _razvertka, x1, _b, x2, _d); DownRight = std::make_unique<PeanoCurve_2D>(Left, _razvertka, x1, _b, _c, x2); break; case Down: TopRight = std::make_unique<PeanoCurve_2D>(Left, _razvertka, x1, _b, x2, _d); DownRight = std::make_unique<PeanoCurve_2D>(Down, _razvertka, x1, _b, _c, x2); DownLeft = std::make_unique<PeanoCurve_2D>(Down, _razvertka, _a, x1, _c, x2); TopLeft = std::make_unique<PeanoCurve_2D>(Right, _razvertka, _a, x1, x2, _d); break; case Right: DownLeft = std::make_unique<PeanoCurve_2D>(Top, _razvertka, _a, x1, _c, x2); DownRight = std::make_unique<PeanoCurve_2D>(Right, _razvertka, x1, _b, _c, x2); TopRight = std::make_unique<PeanoCurve_2D>(Right, _razvertka, x1, _b, x2, _d); TopLeft = std::make_unique<PeanoCurve_2D>(Down, _razvertka, _a, x1, x2, _d); break; case Left: TopRight = std::make_unique<PeanoCurve_2D>(Down, _razvertka, x1, _b, x2, _d); TopLeft = std::make_unique<PeanoCurve_2D>(Left, _razvertka, _a, x1, x2, _d); DownLeft = std::make_unique<PeanoCurve_2D>(Left, _razvertka, _a, x1, _c, x2); DownRight = std::make_unique<PeanoCurve_2D>(Top, _razvertka, x1, _b, _c, x2); } } } } const __declspec(noalias) __forceinline PeanoCurve_2D* HitTest_2D(float x) const noexcept; const __declspec(noalias) __forceinline float FindX_2D(float target_x1, float target_x2) const noexcept;
}; ΠΌΠ½Π΅ Π²Π΅ΡΠ½ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΡΠ½Π½ΡΠΉ ΠΊΠΎΠ΄ Π΄Π»Ρ Π΄Π²ΡΠΌΠ΅ΡΠ½ΠΎΠΉ Π²Π΅ΡΠΊΠΈ ΡΠ΅ΡΠ΅Π· boost::mpi ΡΠ°ΡΠΏΠ°ΡΠ°Π»Π»Π΅Π»Π΅Π½Π½ΡΠΉ - ΡΠ°ΠΊΠΆΠ΅ Π½Π°ΠΏΠΈΡΠΈ ΠΊΠ°ΠΊΠΈΠ΅ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΡΡΡΡ, ΡΠ°ΠΊΠΆΠ΅ ΠΎΠ±ΡΠ°ΡΠΈ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΡΡΡ Π΄Π°Π½Π½ΡΡ - Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½Ρ Π½Π΅ ΠΏΡΠΎΡΡΠΎ ΡΠ°ΠΊ Π° ΠΈΠ· ΡΠΎΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ Π»ΡΡΡΠ΅ΠΉ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΡΡΠΈ Π΄Π°Π½Π½ΡΡ - ΡΠ°ΠΊ ΡΡΠΎ ΡΡΠΈΡΡΠ²Π°ΠΉ ΡΡΠΎ ΠΏΡΠΈ ΡΠ°ΡΠΏΠ°ΡΠ°Π»Π»Π΅Π»ΠΈΠ²Π°Π½ΠΈΠΈ ΠΈ ΡΠΎΡ ΡΠ°Π½ΡΠΉ Ρ ΠΎΡΠΎΡΡΡ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΡΡΡ Π΄Π°Π½Π½ΡΡ , ΡΠ»Π΅Π΄ΠΈ ΡΡΠΎΠ±Ρ ΡΠ²ΠΎΠΉ ΠΊΠΎΠ΄ Π½Π΅ ΡΠ»ΠΈΡΠΊΠΎΠΌ ΡΠΈΠ»ΡΠ½ΠΎ ΠΎΡΡ ΠΎΠ΄ΠΈΠ» ΠΎΡ ΠΌΠΎΠΈΡ ΠΊΠ°Π½ΠΎΠ½ΠΎΠ², ΡΠΎ ΡΡΠΎ Π±ΡΠ΄Π΅Ρ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡΡ Π½Π° ΠΊΠ°ΠΆΠ΄ΠΎΠΌ ΠΏΡΠΎΡΠ΅ΡΡΠ΅ Π°Π»Π³ΠΎΡΠΈΡΠΌΠΈΡΠ΅ΡΠΊΠΈ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΎΡΠ»ΠΈΡΠ°ΡΡΡΡ ΡΠ»ΠΈΡΠΊΠΎΠΌ ΡΠΈΠ»ΡΠ½ΠΎ ΠΎΡ ΡΠΎΠ³ΠΎ ΡΡΠΎ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ Π² ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΠΉ Π²Π΅ΡΡΠΈΠΈ ΠΎΠ΄Π½ΠΎΠΌΠ΅ΡΠ½ΠΎΠΉ Π²Π΅ΡΠΊΠΈ, Π² ΠΊΠΎΠ½ΡΠ΅ Π΄Π°ΠΉ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠΎΠ²Π΅ΡΡ ΠΏΠΎ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ Π½ΠΎ Π½Π΅ Π²Π½ΠΎΡΠΈ ΠΈΡ Π² ΠΊΠΎΠ΄
Π½ΠΈΠΆΠ΅ β Π³ΠΎΡΠΎΠ²Π°Ρ Π·Π°ΠΌΠ΅Π½Π° ΡΠΎΠ»ΡΠΊΠΎ Π΄Π»Ρ Π΄Π²ΡΠΌΠ΅ΡΠ½ΠΎΠΉ Π²Π΅ΡΠΊΠΈ (else
Ρ if (N == 1u)
), ΡΠ°ΡΠΏΠ°ΡΠ°Π»Π»Π΅Π»Π΅Π½Π½Π°Ρ Π½Π° Π΄Π²Π° ΠΏΡΠΎΡΠ΅ΡΡΠ° Boost.MPI ΠΏΠΎ Π²Π°ΡΠ΅ΠΌΡ ΠΏΡΠ°Π²ΠΈΠ»Ρ:
0
ΡΡΠΈΡΠ°Π΅Ρ Β«ΠΎΠ±ΡΡΠ½ΡΡΒ» ΡΠ°Π·Π²ΡΡΡΠΊΡ (Curve
),1
ΡΡΠΈΡΠ°Π΅Ρ ΠΏΠ΅ΡΠ΅Π²ΡΡΠ½ΡΡΡΡ ΡΠ°Π·Π²ΡΡΡΠΊΡ (Curve_Inverted
),all_reduce(max)
Π½Π°Π΄ ΡΠ»Π°Π³ΠΎΠΌ ΠΎΡΡΠ°Π½ΠΎΠ²Π°.Π ΠΎΠ΄Π½ΠΎΡΡΠΎΡΠΎΠ½Π½Π΅ΠΉ ΠΈΠ½ΡΠ΅ΠΊΡΠΈΠΈ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΠΏΡΠΎΡΠ΅ΡΡ ΠΊΠΎΠ½Π²Π΅ΡΡΠΈΡΡΠ΅Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΠ΅ ΠΎΡ Π½Π°ΠΏΠ°ΡΠ½ΠΈΠΊΠ° Π³ΡΠ°Π½ΠΈΡΠ½ΡΠ΅ ΡΠΎΡΠΊΠΈ Π² ΡΠ²ΠΎΠΉ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠ²ΠΎΠ΅ΠΉ ΠΊΡΠΈΠ²ΠΎΠΉ ΠΠ΅Π°Π½ΠΎ, ΡΠΎΡΠΌΠΈΡΡΠ΅Ρ Β«Π²ΠΏΡΡΡΠ½ΡΡΡΠΉΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π» ΠΈ ΠΏΠΎΠΌΠ΅ΡΠ°Π΅Ρ Π΅Π³ΠΎ Π² ΡΠ²ΠΎΡ ΠΊΡΡΡ; Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅
R
Π΄Π»Ρ Β«Π²ΠΏΡΡΡΠ½ΡΡΠΎΠ³ΠΎΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π° Π±Π΅ΡΡΡΡΡ ΠΊΠ°ΠΊk * R_top_ΠΏΠ°ΡΡΠ½ΡΡΠ°
(Π΅Π³ΠΎ ΠΌΡ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΌ Π²ΠΎ Π²Π»ΠΎΠΆΠ΅Π½ΠΈΠΈ ΠΊ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΠ°ΠΌ). ΠΠ½Π°ΡΠ΅Π½ΠΈΡy
Π΄Π»Ρ ΠΊΠΎΠ½ΡΠΎΠ² Β«Π²ΠΏΡΡΡΠ½ΡΡΠΎΠ³ΠΎΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π° ΠΌΡ ΠΏΠ΅ΡΠ΅ΡΡΠΈΡΡΠ²Π°Π΅ΠΌ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎ ΡΠ΅ΡΠ΅Π·RastriginFunc
ΠΏΠΎ ΠΏΡΠΈΡΠ»Π°Π½Π½ΡΠΌ β ΡΡΠΎ ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΎΡΠΈΠ³ΠΈΠ½Π°Π»Ρ (ΡΡΠ½ΠΊΡΠΈΡ ΡΠ° ΠΆΠ΅, ΡΠΎΡΠΊΠΈ ΡΠ΅ ΠΆΠ΅), ΠΏΡΠΈ ΡΡΠΎΠΌ Π½Π°ΠΌ Π½Π΅ Π½ΡΠΆΠ½ΠΎ ΠΏΠ΅ΡΠ΅Π΄Π°Π²Π°ΡΡy
.
Base_LNA_1_2_Mer_AGP
β Π΄Π²ΡΠΌΠ΅ΡΠ½Π°Ρ Π²Π΅ΡΠΊΠ°)cpp// ... Π½Π°ΡΠ°Π»ΠΎ ΡΡΠ½ΠΊΡΠΈΠΈ Base_LNA_1_2_Mer_AGP(...) ΠΎΡΡΠ°ΡΡΡΡ Π±Π΅Π· ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ ... } else { // ====== N != 1u : 2D Π²Π΅ΡΠΊΠ°, ΡΠ°ΡΠΏΠ°ΡΠ°Π»Π»Π΅Π»Π΅Π½ΠΎ ΠΏΠΎ Boost.MPI ====== struct CrossMsg final { float s_x1, s_x2; // start: (x1,x2) float e_x1, e_x2; // end : (x1,x2) float Rtop; // R-Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊΠ° Π²Π΅ΡΡΠΈΠ½Ρ ΠΎΡΠΏΡΠ°Π²ΠΈΡΠ΅Π»Ρ // Boost.Serialization template <typename Archive> void serialize(Archive& ar, const unsigned int) { ar & s_x1 & s_x2 & e_x1 & e_x2 & Rtop; } }; const int32_t rank = world.rank(); const int32_t partner = (rank ^ 1); // ΠΡΠ±ΠΎΡ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠΉ ΡΠ°Π·Π²ΡΡΡΠΊΠΈ ΠΈ Π½Π°ΡΠ°Π»ΡΠ½ΡΡ Π³ΡΠ°Π½ΠΈΡΠ½ΡΡ ΡΡΠ»ΠΎΠ²ΠΈΠΉ β ΡΡΡΠΎΠ³ΠΎ ΠΊΠ°ΠΊ Ρ Π²Π°Ρ, Π½ΠΎ ΡΠ°Π·Π½Π΅ΡΠ΅Π½ΠΎ ΠΏΠΎ ΡΠ°Π½Π³Π°ΠΌ. const PeanoCurve_2D* __restrict LocCurve = (rank == 0) ? Curve.get() : Curve_Inverted.get(); std::vector<float> Extr; Extr.reserve(3u * global_iterations + 2u); std::vector<Interval> R; R.reserve(global_iterations + 1u); // ΠΠ΅ΠΎΠΌΠ΅ΡΡΠΈΡ Β«Π·Π°ΡΠΈΡΠ½ΠΎΠΉ ΡΠ°ΠΌΠΊΠΈΒ» ΠΊΠ°ΠΊ Π² ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠ΅: ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²Π°Ρ Π΄Π»Ρ ΠΎΠ±ΠΎΠΈΡ ΡΠ°Π½Π³ΠΎΠ². const float divider = 1u << (2u * (LocCurve ? LocCurve->razvertka : 0u) + 1u); const float x_addition = (b - a) / divider; const float y_addition = (d - c) / divider; const float true_start = a + x_addition; const float true_end = b - x_addition; const float initial_length = true_end - true_start; float dmax = initial_length; uint32_t schetchick = 0u; // Π‘ΡΠ°ΡΡΠΎΠ²ΡΠ΅ ΡΠΎΡΠΊΠΈ ΠΈ Π·Π½Π°ΡΠ΅Π½ΠΈΡ β ΡΠΎΠ³Π»Π°ΡΠ½ΠΎ Π²Π°ΡΠ΅ΠΉ Β«Π΄Π²ΠΎΠΉΠ½ΠΎΠΉΒ» Π»ΠΎΠ³ΠΈΠΊΠ΅, // Π½ΠΎ ΠΊΠ°ΠΆΠ΄Π°Ρ Π²Π΅ΡΠΊΠ° ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ ΡΠ²ΠΎΡ ΡΡΠΎΡΠΎΠ½Ρ. std::pair<float, float> start, end; if (rank == 0) { // ΠΠ±ΡΡΠ½Π°Ρ ΡΠ°Π·Π²ΡΡΡΠΊΠ° (Curve) start = std::make_pair(true_start, RastriginFunc(true_start, c + y_addition)); end = std::make_pair(true_end, RastriginFunc(true_end, c + y_addition)); } else { // ΠΠ΅ΡΠ΅Π²ΡΡΠ½ΡΡΠ°Ρ ΡΠ°Π·Π²ΡΡΡΠΊΠ° (Curve_Inverted) start = std::make_pair(true_start, RastriginFunc(true_end, d - y_addition)); end = std::make_pair(true_end, RastriginFunc(true_start, d - y_addition)); } std::pair<float, float> x_Rmax = std::make_pair(start.first, end.first); std::pair<float, float> y_Rmax = std::make_pair(start.second, end.second); Interval initial_interval(start, end, N); float Mmax = initial_interval.M; float m = r * Mmax; R.emplace_back(std::move(initial_interval)); // ΠΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ Π»ΡΡΡΠΈΠΉ β ΠΊΠ°ΠΆΠ΄ΡΠΉ ΠΏΡΠΎΡΠ΅ΡΡ Π²Π΅Π΄ΡΡ ΡΠ²ΠΎΠΉ best_f; Π³Π»ΠΎΠ±Π°Π»ΡΠ½ΡΠΉ ΠΎΠ±ΠΌΠ΅Π½ Π»ΡΡΡΠΈΠΌ ΠΌΡ ΡΠΎΠ·Π½Π°ΡΠ΅Π»ΡΠ½ΠΎ Π½Π΅ Π΄Π΅Π»Π°Π΅ΠΌ (Π΄ΠΎΡΠΎΠ³ΠΎ). float best_f = end.second; // ΠΡΠ½ΠΎΠ²Π½ΠΎΠΉ ΡΠΈΠΊΠ» while (true) { // 1) ΠΠ»ΠΎΠ±Π°Π»ΡΠ½Π°Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° ΠΎΡΡΠ°Π½ΠΎΠ²Π° ΠΏΠΎ ΠΈΡΠ΅ΡΠ°ΡΠΈΡΠΌ if (++schetchick == global_iterations) { const Interval& top = R.front(); const float len = top.end.first - top.start.first; Extr.emplace_back(len); Extr.emplace_back(global_iterations); // Π‘ΠΈΠ³Π½Π°Π» Β«ΡΡΠΎΠΏΒ» Π²ΡΠ΅ΠΌ int my_stop = 1; int any_stop = 0; boost::mpi::all_reduce(world, my_stop, any_stop, boost::mpi::maximum<int>()); break; } // Π’Π΅ΠΊΡΡΠΈΠΉ Β«Π»ΡΡΡΠΈΠΉΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π» Π² ΠΊΡΡΠ΅ const float x1L = x_Rmax.first; const float x2L = x_Rmax.second; const float y1L = y_Rmax.first; const float y2L = y_Rmax.second; // 2) Π¨Π°Π³ ΠΏΠΎΠΈΡΠΊΠ° ΠΏΠΎ Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊΠ°ΠΌ const float new_param = Shag(m, x1L, x2L, y1L, y2L, N, r); const PeanoCurve_2D* __restrict p = LocCurve->HitTest_2D(new_param); const float new_x1 = p->x1; const float new_x2 = p->x2; const float new_value = RastriginFunc(new_x1, new_x2); const std::pair<float, float> promejutochnaya_tochka(new_param, new_value); if (new_value < best_f) { best_f = new_value; Extr.emplace_back(best_f); Extr.emplace_back(new_x1); Extr.emplace_back(new_x2); } // 3) Π Π°Π·Π΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π°, ΠΊΠ°ΠΊ Ρ Π²Π°Ρ std::pop_heap(R.begin(), R.end(), Compare); const Interval promejutochny_otrezok = std::move(R.back()); R.pop_back(); Interval curr (promejutochny_otrezok.start, promejutochnaya_tochka, N); Interval curr1(promejutochnaya_tochka, promejutochny_otrezok.end, N); const float currM = curr1.M > curr.M ? curr1.M : curr.M; const float len2 = promejutochny_otrezok.end.first - new_param; const float len1 = new_param - promejutochny_otrezok.start.first; const size_t r_size = R.size(); if (len2 + len1 == dmax) { dmax = len2 > len1 ? len2 : len1; #pragma loop(ivdep) for (size_t i = 0u; i < r_size; ++i) { const float l = R[i].end.first - R[i].start.first; if (l > dmax) { dmax = l; } } } // 4) ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊ (Π°Π΄Π°ΠΏΡΠΈΠ²Π½ΡΠΉ/Π½Π΅Π°Π΄Π°ΠΏΡΠΈΠ²Π½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ) β ΡΡΡΠΎΠ³ΠΎ ΠΏΠΎ Π²Π°ΡΠ΅ΠΌΡ ΡΠ°Π±Π»ΠΎΠ½Ρ if (mode) { const float threshold_03 = 0.3f * initial_length; if (threshold_03 > dmax && schetchick % 3u == 0u || 10.0f * dmax < initial_length) { if (currM > Mmax) { Mmax = currM; m = r * Mmax; } const float inv_threshold_03 = 1.0f / threshold_03; const float progress = fmaf(-inv_threshold_03, dmax, 1.0f); const float alpha = fmaf(progress, progress, 1.0f); const float betta = 2.0f - alpha; const float inv_dmax = 1.0f / dmax; const float MULTIPLIER = inv_dmax * Mmax; const float global_coeff = fmaf(MULTIPLIER, r, -MULTIPLIER); const float GLOBAL_FACTOR = betta * global_coeff; curr .ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len1, curr .M * alpha), N); curr1.ChangeCharacteristic(fmaf(GLOBAL_FACTOR, len2, curr1.M * alpha), N); #pragma loop(ivdep) for (size_t i = 0u; i < r_size; ++i) { const float li = R[i].end.first - R[i].start.first; R[i].ChangeCharacteristic(fmaf(GLOBAL_FACTOR, li, R[i].M * alpha), N); } std::make_heap(R.begin(), R.end(), Compare); } else { if (currM > Mmax) { Mmax = currM; m = r * Mmax; curr .ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); #pragma loop(ivdep) for (size_t i = 0u; i < r_size; ++i) { R[i].ChangeCharacteristic(m, N); } std::make_heap(R.begin(), R.end(), Compare); } else { curr .ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); } } } else { if (currM > Mmax) { Mmax = currM; m = r * Mmax; curr .ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); #pragma loop(ivdep) for (size_t i = 0u; i < r_size; ++i) { R[i].ChangeCharacteristic(m, N); } std::make_heap(R.begin(), R.end(), Compare); } else { curr .ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); } } // 5) ΠΠΎΠΌΠ΅ΡΡΠΈΡΡ ΠΎΠ±Π° ΠΏΠΎΠ΄ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π° ΠΎΠ±ΡΠ°ΡΠ½ΠΎ R.emplace_back(std::move(curr)); std::push_heap(R.begin(), R.end(), Compare); R.emplace_back(std::move(curr1)); std::push_heap(R.begin(), R.end(), Compare); // 6) ΠΠΎΡΠ΅Π½ΡΠΈΠ°Π»ΡΠ½Π°Ρ ΠΠ ΠΠ‘Π‘-ΠΠΠͺΠΠΠ¦ΠΠ― (ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎΠ΅ ΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΡΠΎΠ»ΡΠΊΠΎ Π·Π΄Π΅ΡΡ) { const float cooling = expf(-schetchick / 200.0f); const uint32_t T = fmaf(20.0f, cooling, 10.0f); const float k = fmaf(0.2f, cooling, 0.7f); // ΠΠΎΠΊΠ°Π»ΡΠ½ΠΎΠ΅ ΡΠ΅ΡΠ΅Π½ΠΈΠ΅ Β«Π³ΠΎΡΠΎΠ² ΠΈΠ½ΡΠ΅ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ?Β» int do_inject_local = (schetchick % T == 0u && schetchick > T && !R.empty()) ? 1 : 0; int do_inject_all = 0; // ΠΠ½ΡΠ΅ΠΊΡΠΈΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½Π° ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΠΈ ΠΆΠ΅Π»Π°Π½ΠΈΠΈ ΠΠΠΠΠ₯ boost::mpi::all_reduce(world, do_inject_local, do_inject_all, boost::mpi::minimum<int>()); if (do_inject_all) { // Π‘ΠΎΠ±ΠΈΡΠ°Π΅ΠΌ Π΄Π°Π½Π½ΡΠ΅ ΡΠ²ΠΎΠ΅ΠΉ Π²Π΅ΡΡΠΈΠ½Ρ const Interval& topL = R.front(); const PeanoCurve_2D* __restrict p1L = LocCurve->HitTest_2D(topL.start.first); const PeanoCurve_2D* __restrict p2L = LocCurve->HitTest_2D(topL.end.first); CrossMsg outbound { p1L->x1, p1L->x2, p2L->x1, p2L->x2, topL.R }; CrossMsg inbound; // Π‘ΠΈΠΌΠΌΠ΅ΡΡΠΈΡΠ½ΡΠΉ Π΄Π²ΡΡΡΠΎΡΠΎΠ½Π½ΠΈΠΉ ΠΎΠ±ΠΌΠ΅Π½ (Π±Π΅Π· Π±Π»ΠΎΠΊΠΈΡΠΎΠ²ΠΎΠΊ ΠΎΡΠ΅ΡΠ΅Π΄Π½ΠΎΡΡΠΈ) boost::mpi::request reqs[2]; reqs[0] = world.isend(partner, /*tag*/ 1, outbound); reqs[1] = world.irecv(partner, /*tag*/ 1, inbound); boost::mpi::wait_all(reqs, reqs + 2); // ΠΠ°ΠΏΠΏΠΈΠ½Π³ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ ΠΏΠ°ΡΡΠ½ΡΡΠ° Π² Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ const float newParam1_remote = LocCurve->FindX_2D(inbound.s_x1, inbound.s_x2); const float newParam2_remote = LocCurve->FindX_2D(inbound.e_x1, inbound.e_x2); // y Π½Π° ΠΊΠΎΠ½ΡΠ°Ρ ΠΏΠ΅ΡΠ΅ΡΡΠΈΡΡΠ²Π°Π΅ΠΌ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎ ΠΏΠΎ ΠΏΡΠΈΡΠ»Π°Π½Π½ΡΠΌ (x1,x2) β ΡΡΠΎ ΡΠΎΡ ΠΆΠ΅ f() const std::pair<float, float> newStart_remote(newParam1_remote, RastriginFunc(inbound.s_x1, inbound.s_x2)); const std::pair<float, float> newEnd_remote(newParam2_remote, RastriginFunc(inbound.e_x1, inbound.e_x2)); Interval injected(newStart_remote, newEnd_remote, N); injected.R = inbound.Rtop * k; // ΠΊΠ°ΠΊ Π² ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠ΅: ΠΌΠ°ΡΡΡΠ°Π± ΠΎΡ Π²Π΅ΡΡΠΈΠ½Ρ Β«Π΄ΠΎΠ½ΠΎΡΡΠΊΠΎΠΉΒ» ΡΡΠΎΡΠΎΠ½Ρ R.emplace_back(std::move(injected)); std::push_heap(R.begin(), R.end(), Compare); } } // 7) ΠΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΠΏΠΎ ΡΠΎΡΠ½ΠΎΡΡΠΈ const Interval& top = R.front(); const float interval_length = top.end.first - top.start.first; if (interval_length < epsilon) { Extr.emplace_back(interval_length); Extr.emplace_back(schetchick); int my_stop = 1; int any_stop = 0; boost::mpi::all_reduce(world, my_stop, any_stop, boost::mpi::maximum<int>()); break; } // ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Β«ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½ΠΎΠ³ΠΎΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π° x_Rmax = std::make_pair(top.start.first, top.end.first); y_Rmax = std::make_pair(top.start.second, top.end.second); // 8) ΠΠ»ΠΎΠ±Π°Π»ΡΠ½ΡΠΉ ΡΠ»Π°ΠΆΠΎΠΊ ΠΎΡΡΠ°Π½ΠΎΠ²Π° β Π΅ΡΠ»ΠΈ Π½Π°ΠΏΠ°ΡΠ½ΠΈΠΊ ΡΠΆΠ΅ ΠΎΡΡΠ°Π½ΠΎΠ²ΠΈΠ»ΡΡ (ΠΈΠ»ΠΈ ΠΌΡ), Π²ΡΡ ΠΎΠ΄ΠΈΠΌ ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎ { int my_stop = 0; int any_stop = 0; boost::mpi::all_reduce(world, my_stop, any_stop, boost::mpi::maximum<int>()); if (any_stop) { break; } } } return Extr; } // ... ΠΊΠΎΠ½Π΅Ρ ΡΡΠ½ΠΊΡΠΈΠΈ Base_LNA_1_2_Mer_AGP(...)
cpp#include <vector> #include <utility> #include <algorithm> // heap ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ #include <boost/mpi.hpp> #include <boost/serialization/access.hpp> #include <boost/serialization/serialization.hpp>
(ΠΠΎΠ»ΡΡΠ΅ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ: ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΡΡ CrossMsg
ΡΠΎ Π²ΡΡΡΠΎΠ΅Π½Π½ΠΎΠΉ Boost.Serialization, Π±Π΅Π· ΡΠΊΠ·ΠΎΡΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΠΎΠ².)
Interval
, Π½Π΅ ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΏΠΎΡΡΠ΄ΠΎΠΊ Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΠΉ Π² Π³ΠΎΡΡΡΠ΅ΠΌ ΡΠΈΠΊΠ»Π΅.R
Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ° ΠΈΠ·ΠΎΠ»ΠΈΡΠΎΠ²Π°Π½Ρ; ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ Ρ
Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊ (ChangeCharacteristic
) Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎ Π½Π°Π΄ ΡΠ²ΠΎΠΈΠΌΠΈ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌΠΈ.R
Π²Π΅ΡΡΠΈΠ½Ρ-Π΄ΠΎΠ½ΠΎΡΠ° Π΄Π»Ρ ΠΌΠ°ΡΡΡΠ°Π±ΠΈΡΠΎΠ²Π°Π½ΠΈΡ k
.y
Π΄Π»Ρ ΠΊΠΎΠ½ΡΠΎΠ² Β«Π²ΠΏΡΡΡΠ½ΡΡΠΎΠ³ΠΎΒ» ΠΈΠ½ΡΠ΅ΡΠ²Π°Π»Π° Π½Π΅ ΡΠ»ΡΠΌ, Π° ΠΏΠ΅ΡΠ΅ΡΡΠΈΡΡΠ²Π°Π΅ΠΌ: ΡΡΠΎ ΡΠ° ΠΆΠ΅ ΡΠΎΡΠΊΠ° Π² , ΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎ ΡΠΎΡ ΠΆΠ΅ f
, ΠΊΡΡ Π·Π΄Π΅ΡΡ Π½Π΅ ΡΡΡΠ°Π΄Π°Π΅Ρ (Π²ΡΠ·ΠΎΠ² ΠΊΡΠ°ΠΉΠ½Π΅ Π΄Π΅ΡΡΠ²ΡΠΉ).Shag
, ΡΠ°Π·Π±ΠΈΠ΅Π½ΠΈΠ΅, Π°Π΄Π°ΠΏΡΠ°ΡΠΈΡ m
, ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠ° dmax
, Π»ΠΎΠ³ΠΈΠΊΠ° ΠΎΡΡΠ°Π½ΠΎΠ²Π°, β Π½Π΅ΠΈΠ·ΠΌΠ΅Π½Π½Ρ.CrossMsg
ΠΈ ΠΎΡΠΏΡΠ°Π²Π»ΡΡΡ ΠΎΠ΄Π½ΠΈΠΌ world.isend()
Π±Π°ΡΡΠ΅ΠΌ (ΠΌΠ°ΡΡΠΈΠ²), ΡΠΌΠ΅Π½ΡΡΠ°Ρ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΎΠ±ΠΌΠ΅Π½ΠΎΠ².all_reduce
β ΡΠ΅Π΄ΠΊΠ°Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° (ΡΠ°Π· Π² K
ΠΈΡΠ΅ΡΠ°ΡΠΈΠΉ) ΠΈ/ΠΈΠ»ΠΈ Π½Π΅Π±Π»ΠΎΠΊΠΈΡΡΡΡΠΈΠΉ ΠΎΠ±ΠΌΠ΅Π½ ΡΠ»Π°ΠΆΠΊΠ°ΠΌΠΈ (polling iprobe
).R
ΠΈ Π±ΡΡΠ΅ΡΡ ΠΏΠΎΠ΄ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΠΉ ΡΠ°Π½ΠΊ/ΠΏΠΎΡΠΎΠΊ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ reserve
Ρ Π·Π°ΠΏΠ°ΡΠΎΠΌ, ΠΈΠ·Π±Π΅Π³Π°ΡΡ ΡΠ΅Π°Π»Π»ΠΎΠΊΠ°ΡΠΈΠΉ; ΡΠ°ΡΡΠΌΠΎΡΡΠ΅ΡΡ customβallocator Ρ 64-Π±Π°ΠΉΡΠΎΠ²ΡΠΌ Π²ΡΡΠ°Π²Π½ΠΈΠ²Π°Π½ΠΈΠ΅ΠΌ.RastriginFunc
Π²ΡΠ·ΡΠ²Π°Π΅Ρ fabe13_cos
, ΡΠ±Π΅Π΄ΠΈΡΡΡΡ, ΡΡΠΎ ΠΎΠ½Π° LTO/inlined; Π΄Π»Ρ sincos
Π±Π»ΠΎΠΊΠΎΠ² β Π½Π΅ Π²ΡΠ·ΡΠ²Π°ΡΡ ΠΈΡ
Π² 2D Π²Π΅ΡΠΊΠ΅ Π² Π³ΠΎΡΡΡΠ΅ΠΌ ΡΠΈΠΊΠ»Π΅ (ΡΠ΅ΠΉΡΠ°Ρ ΠΈ ΡΠ°ΠΊ Π½Π΅ Π²ΡΠ·ΡΠ²Π°ΡΡΡΡ).ChangeCharacteristic
β Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, ΡΡΠΎΠΈΡ Π²Π΅ΠΊΡΠΎΡΠΈΠ·ΠΎΠ²Π°ΡΡ Β«ΠΌΠ°ΡΡΠΎΠ²ΡΠΉΒ» ΠΏΡΠΎΡ
ΠΎΠ΄ ΠΏΠΎ ΠΊΡΡΠ΅ (ΡΡΡΠΎΠ³ΠΈΠ΅ alias-ΠΊΠ²Π°Π»ΠΈΡΠΈΠΊΠ°ΡΠΎΡΡ Ρ Π²Π°Ρ ΡΠΆΠ΅ ΡΡΠΎΡΡ).xor_rand_*
Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ TU).Π΅ΡΠ»ΠΈ Π·Π°Ρ ΠΎΡΠΈΡΠ΅ β ΠΌΠΎΠ³Ρ Π΄Π°ΡΡ Π²Π°ΡΠΈΠ°Π½Ρ Ρ Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΡΠΌΠΈ Β«ΠΏΠΎΡΡΠΎΠ²ΡΠΌΠΈ ΡΡΠΈΠΊΠ°ΠΌΠΈΒ» Π΄Π»Ρ ΠΊΡΠΎΡΡ-ΠΈΠ½ΡΠ΅ΠΊΡΠΈΠΉ (Π½Π΅Π·Π°Π²ΠΈΡΠΈΠΌΡΠ΅ ΡΠ΅ΠΌΠΏΡ ΡΠ°Π½ΠΊΠΎΠ², Π±Π΅Π· all-reduce Π½Π° ΠΊΠ°ΠΆΠ΄ΠΎΠΌ ΡΠ°Π³Π΅).