相关疑难解决方法(0)

为什么gcc autovectorization对3x3的卷积矩阵不起作用?

我已经为卷积矩阵实现了以下程序

#include <stdio.h>
#include <time.h>

#define NUM_LOOP 1000
#define N 128   //input or output dimention 1
#define M N     //input or output dimention 2
#define P 5 //convolution matrix dimention 1 if you want a 3x3 convolution matrix it must be 3
#define Q P     //convolution matrix dimention 2
#define Csize P*Q   
#define Cdiv  1     //div for filter 
#define Coffset 0   //offset 

//functions
void unusual(); //unusual implementation of convolution
void naive();
//data
unsigned short int input[N][M] __attribute__(( aligned(32))); // input …
Run Code Online (Sandbox Code Playgroud)

c x86 gcc compiler-optimization auto-vectorization

10
推荐指数
1
解决办法
363
查看次数

C++ 指向布尔值的指针

我在尝试实现一个包含指向布尔值的指针的类时遇到问题...

class BoolHolder {
    public:
    BoolHolder(bool* _state);

    bool* state;
}

BoolHolder::BoolHolder(bool* _state) {
    state = _state;
}

bool testbool = false;

BoolHolder testbool_holder( &testbool );
Run Code Online (Sandbox Code Playgroud)

如果我这样做,testbool_holder.state 总是报告它是真的,不管 testbool 本身是真还是假

我究竟做错了什么?我只是希望该类能够为 testbool 维护一个最新的值,但我不知道如何实现这一点。谢谢

c++ pointers boolean

5
推荐指数
1
解决办法
3万
查看次数