Hillis & Steele 平行前缀和 C 题

问题描述 投票:0回答:0

这是我要实现的伪代码:

enter image description here

这是我当前的代码:

extern "C" {
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>

    int ParPrefix(          
        const unsigned int *in1, // Read-Only Vector
            unsigned int *out,       // Output Result
            int size                 // Size in integer
        )
    {
#pragma HLS INTERFACE m_axi port=in1 bundle=aximm1
#pragma HLS INTERFACE m_axi port=out bundle=aximm1

            int stages = ceil(log2(size)); // Number of stages

            // Compute prefix sum for each stage
            for (int i = 0; i < stages; i++) {
                for (int j = 0; j < size; j++) {
                        if (j >= pow(2, i)) {
                            int k = j - pow(2, i);
                            out[j] = in1[j] + in1[k];
                        } else {
                            out[j] = in1[j];
                        }
                }
            }
        return 0;
    }
}

我正在对照这段代码检查它:

enter image description here

我得到这个作为我的输出:

enter image description here\

关于我做错了什么有什么想法吗?

见上文......................

c opencl fpga
© www.soinside.com 2019 - 2024. All rights reserved.