Skip to content

#1826 SIMD-512 Systems Fail When Decoding MPT1327 #1832

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

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
* Copyright (C) 2014-2024 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,7 @@

package io.github.dsheirer.dsp.oscillator;

import java.util.Arrays;
import jdk.incubator.vector.FloatVector;
import jdk.incubator.vector.VectorOperators;
import jdk.incubator.vector.VectorSpecies;
Expand All @@ -45,7 +46,15 @@ public VectorRealOscillator(double frequency, double sampleRate)
@Override
public float[] generate(int sampleCount)
{
float[] samples = new float[sampleCount];
int length = sampleCount;

//Increase the length until it aligns as a multiple of the vector species length
while(length % VECTOR_SPECIES.length() != 0)
{
length++;
}

float[] samples = new float[length];

for(int samplePointer = 0; samplePointer < sampleCount; samplePointer += VECTOR_SPECIES.length())
{
Expand All @@ -58,6 +67,7 @@ public float[] generate(int sampleCount)
generated.intoArray(samples, samplePointer);
}

return samples;
//Truncate the array to the requested length, if we increased it for SIMD alignment.
return Arrays.copyOf(samples, sampleCount);
}
}