Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove AlignedBuf and replace with alignas(n) std::array #3411

Open
wants to merge 1 commit into
base: community
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/deluge/dsp/dx/EngineMkI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using std::max;
using std::min;

const int32_t __attribute__((aligned(16))) zeros[DX_MAX_N] = {0};
alignas(16) const int32_t zeros[DX_MAX_N] = {0};

Check failure on line 34 in src/deluge/dsp/dx/EngineMkI.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy-review

clang-tidy: error

do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]

static const uint16_t NEGATIVE_BIT = 0x8000;
static const uint16_t ENV_BITDEPTH = 14;
Expand Down Expand Up @@ -255,7 +255,7 @@
FmOpParams& param = params[op];
int inbus = (flags >> 4) & 3;
int outbus = flags & 3;
int32_t* outptr = (outbus == 0) ? output : buf_[outbus - 1].get();
int32_t* outptr = (outbus == 0) ? output : buf_[outbus - 1].data();
int32_t gain1 = param.gain_out == 0 ? (ENV_MAX - 1) : param.gain_out;
int32_t gain2 = ENV_MAX - (param.level_in >> (28 - ENV_BITDEPTH));
param.gain_out = gain2;
Expand Down Expand Up @@ -303,7 +303,7 @@
}
}
else {
compute(outptr, n, buf_[inbus - 1].get(), param.phase, param.freq, gain1, gain2, dgain, add);
compute(outptr, n, buf_[inbus - 1].data(), param.phase, param.freq, gain1, gain2, dgain, add);
}

has_contents[outbus] = true;
Expand Down
1 change: 0 additions & 1 deletion src/deluge/dsp/dx/EngineMkI.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#pragma once

#include "aligned_buf.h"
#include "fm_core.h"
#include "fm_op_kernel.h"

Expand Down
32 changes: 0 additions & 32 deletions src/deluge/dsp/dx/aligned_buf.h

This file was deleted.

6 changes: 3 additions & 3 deletions src/deluge/dsp/dx/fm_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void FmCore::render(int32_t* output, int n, FmOpParams* params, int algorithm, i
FmOpParams& param = params[op];
int inbus = (flags >> 4) & 3;
int outbus = flags & 3;
int32_t* outptr = (outbus == 0) ? output : buf_[outbus - 1].get();
int32_t* outptr = (outbus == 0) ? output : buf_[outbus - 1].data();
int32_t gain1 = param.gain_out;
int32_t gain2 = Exp2::lookup(param.level_in - (14 * (1 << 24)));
param.gain_out = gain2;
Expand All @@ -106,8 +106,8 @@ void FmCore::render(int32_t* output, int n, FmOpParams* params, int algorithm, i
}
else {
// cout << op << " normal " << inbus << outbus << " " << param.freq << add << endl;
FmOpKernel::compute(outptr, simd_n, buf_[inbus - 1].get(), param.phase, param.freq, gain1, gain2, dgain,
add, neon);
FmOpKernel::compute(outptr, simd_n, buf_[inbus - 1].data(), param.phase, param.freq, gain1, gain2,
dgain, add, neon);
}
has_contents[outbus] = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/deluge/dsp/dx/fm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

#pragma once

#include "aligned_buf.h"
#include "fm_op_kernel.h"
#include <array>

#define div_n(base, inv_n) ((int)((((int64_t)(base)) * (int64_t)(inv_n)) >> 30))

Expand Down Expand Up @@ -59,5 +59,5 @@ class FmCore {
bool neon = false;

protected:
AlignedBuf<int32_t, DX_MAX_N> buf_[2];
alignas(16) std::array<int32_t, DX_MAX_N> buf_[2];
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this like cache line size /4?

Copy link
Collaborator Author

@stellar-aria stellar-aria Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/2 actually, since AlignedBuf's default for the template argument for alignment was 16 and our cache line size is 32

Loading