__m256d deltaWeightVector = _mm256_set1_pd(deltaWeight);
// The pointers are updated to the next stored value by jumping X doubles ahead depending on the container they are pointing to.
// 4 doubles are for MPointArrays and 3 doubles are for MVectorArrays
for (unsigned int vertexIndex{ start }; vertexIndex < end; ++vertexIndex, currentVertexPosition += 4, currentDeltaVector += 3 ) {
__m256d vertexPosition = _mm256_load_pd(currentVertexPosition);
// Deltas contains 3 relevant values. 4 doubles are loaded for AVX vectors so the last value must be masked.
// Positive number ( whose highest bit is one ) mask that data to zero.
__m256i deltaMask = _mm256_setr_epi32(-1, -1, -1, 1, 1, 1, 1, 1);
__m256d deltaVector = _mm256_maskload_pd(currentDeltaVector, deltaMask);
__m256d resultPosition = _mm256_fmadd_pd(deltaVector, deltaWeightVector, vertexPosition);
// Calculate the (x, y, z, w) values for the result position and stores them in the correct memory address
currentVertexPosition[0] = (currentDeltaVector[0] * deltaWeight) + currentVertexPosition[0];
currentVertexPosition[1] = (currentDeltaVector[1] * deltaWeight) + currentVertexPosition[1];
currentVertexPosition[2] = (currentDeltaVector[2] * deltaWeight) + currentVertexPosition[2];
currentVertexPosition[3] = 1.0;
double* res = (double*)&resultPosition;
std::cout << "Values: " << currentVertexPosition[0] << ", " << currentVertexPosition[1] << ", " << currentVertexPosition[2] << ", " << currentVertexPosition[3] << ", " << std::endl;
std::cout << "VectorValues" << res[0] << ", " << res[1] << ", " << res[2] << ", " << res[3] << ", " << std::endl;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.