One of our x64 AVX code tests we have fails when run on ARM The test results say:
-------------------------------------------------------------------------------
AVX Stacking, Entropy
One image
-------------------------------------------------------------------------------
/Users/amonra/.vs/DSS/DeepSkyStackerTest/AvxStackingTest.cpp:381
...............................................................................
/Users/amonra/.vs/DSS/DeepSkyStackerTest/AvxStackingTest.cpp:416: FAILED:
REQUIRE( avxEntropy.getRedEntropyLayer()[10] == 1.0f )
with expansion:
0.99993f == 1.0f
The test code:
TEST_CASE("AVX Stacking, Entropy", "[AVX][Stacking][Entropy]")
{
SECTION("One image")
{
constexpr int W = 61;
constexpr int H = 37;
typedef float T;
DSSRect rect(0, 0, W, H); // left, top, right, bottom
std::shared_ptr<CMemoryBitmap> pTempBitmap = std::make_shared<CGrayBitmapT<T>>();
REQUIRE(pTempBitmap->Init(W, H) == true);
std::shared_ptr<CMemoryBitmap> pBitmap = std::make_shared<CGrayBitmapT<T>>();
REQUIRE(pBitmap->Init(W, H) == true);
auto* pGray = dynamic_cast<CGrayBitmapT<T>*>(pBitmap.get());
for (int i = 0; i < W * H; ++i)
pGray->m_vPixels[i] = 100.0f;
std::shared_ptr<CMemoryBitmap> pEntropyCoverage = std::make_shared<CGrayBitmapT<float>>();
REQUIRE(pEntropyCoverage->Init(W, H) == true);
TestEntropyInfo entropyInfo;
entropyInfo.Init(pTempBitmap, 10, nullptr);
AvxEntropy avxEntropy(*pTempBitmap, entropyInfo, pEntropyCoverage.get());
CPixelTransform pixTransform;
CTaskInfo taskInfo; // Determines if method is ENTROPY or not.
taskInfo.SetMethod(MBP_ENTROPYAVERAGE, 2, 5);
CBackgroundCalibration backgroundCalib;
backgroundCalib.SetMode(BCM_NONE, BCI_LINEAR, RBCM_MAXIMUM);
AvxStacking avxStacking(0, H, *pBitmap, *pTempBitmap, rect, avxEntropy);
REQUIRE(avxStacking.stack(pixTransform, taskInfo, backgroundCalib, std::shared_ptr<CMemoryBitmap>{}, 1) == 0);
for (int i = 0; i < 10; ++i)
REQUIRE(avxEntropy.getRedEntropyLayer()[i] == Approx(1.0f).epsilon(1e-4f));
REQUIRE(avxEntropy.getRedEntropyLayer()[10] == 1.0f);
The test passes when run on x64 hardware.
The full code for the AvxStacking class is a bit large to post inline. Sadly the attach file option won't let me attach cpp files
D.
One of our x64 AVX code tests we have fails when run on ARM
So you’re talking about Rosetta here, right?
If so, there are a bunch of factors to consider here. First, the goal of Rosetta is to support the transition from Intel to Apple silicon by providing binary compatibility for existing products. If you’re creating new products, you should be building for Apple silicon rather than for Intel. So, if you do the equivalent thing in Apple silicon [1], does it have the same problem?
OTOH, if you have an existing product and this test indicates that your product would fail for actual users, it definitely makes sense to file a bug against Rosetta itself. In this case, make sure that your bug explains the user impact of this issue.
OTOOH, even if you have an Apple silicon product, having Rosetta around is super useful for day-to-day testing. So it might make sense to file a bug even if you don’t have an existing product.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] My pro tip on this front is to use simd, which allows you to write vector code in an architecture-independent way.