小编Fea*_*nor的帖子

AVX计算精度

我写了一个程序来显示mandelbrot集.为了加快速度,我通过<immintrin.h>标题使用了AVX(真正的AVX2)指令.
问题是:AVX计算的结果(具有双精度)具有伪像,并且它与使用"正常"双精度计算时的结果不同.
详细地,存在一个函数getIterationCount,该函数计算直到曼德尔布尔序列超过4的迭代次数,或假设如果序列在前N个步骤期间不超过4则该点包括在该组中.
代码如下所示:

#include "stdafx.h"
#include <iostream>
#include <complex>
#include <immintrin.h>

class MandelbrotSet {
public:
    int getIterationCount(const std::complex<double>, const int) const noexcept;
    __m256i getIterationCount(__m256d cReal, __m256d cIm, unsigned maxIterations) const noexcept;
};

inline int MandelbrotSet::getIterationCount(const std::complex<double> c, const int maxIterations) const noexcept
{
    double currentReal = 0;
    double currentIm = 0;
    double realSquare;
    double imSquare;
    for (int i = 0; i < maxIterations; ++i) {
        realSquare = currentReal * currentReal;
        imSquare = currentIm * currentIm; …
Run Code Online (Sandbox Code Playgroud)

c++ mandelbrot avx avx2

4
推荐指数
1
解决办法
230
查看次数

标签 统计

avx ×1

avx2 ×1

c++ ×1

mandelbrot ×1