需要使用Arm Fast Models提供的全新的SVE模型来解决此问题。具体步骤如下:
下载最新版本的Fast Models。
在代码中使用Fast Models中的SVE模型,代码示例如下:
#include "sg/SVE.h"
using namespace sg;
using namespace Arm;
// Define a vector length of 128 bytes.
#define VL 16
// Create an array of 16-bit integers, with a required buffer alignment of 128 bytes.
int16_t data[VL] __attribute__((aligned(128)));
// Initialise an SVE vector with data.
svint16_t vec = svld1_s16(vl, &data[0]);
// Broadcast a scalar value to all elements of the SVE vector.
svint16_t broadcasted_vec = svdup_n_s16(scalar);
// Add the vector together with a scalar value.
svint16_t add_res = svadd_s16_moverw(vec, broadcasted_vec));
// Store the result back into memory.
svst1_s16(vl, &data[0], add_res);
Initializer
类的子类中添加以下SVE初始化代码片段,以指明仿真使用的特性级:#include "sg/SGParseText.h"
#include "sg/SVEIface.h"
using namespace sg;
using namespace Arm;
class ExampleInit : public sg::Initializer
{
public:
virtual void initialize();
};
void ExampleInit::initialize()
{
// Get the SVE model interface.
auto sve = getModelTreeNode()->unsafe_get_interface();
// Set the vector length on the SVE model.
sve->setVectorLength(2048);
// Set the implementation to use.
sve->setSVEArchitecture(ArchSVE::ArmSVELevel2);
}