Skip to content

Optimize WordAlignmentMatrix for SIMD #7

Description

@pmachapman

The WordAlignmentMatrix class is not optimized for SIMD using OpenMP.

Improvements that can can be made include:

  1. Use uint8_t instead of boolean.
  2. Flatten the matrix from 2d array to a std::vector<uint8_t> matrix; or similar.
  3. Update swAlignModel_getBestAlignment to use the new matrix structure.
  4. Flatting the loops, and add openmp pragmas, e.g.:
#pragma omp simd
for (size_t idx = 0; idx < I * J; ++idx) {
    matrix[idx] = 0;
}

Some loops can probably be parallelized using: #pragma omp parallel for

OpenMP experimental will need to be enabled for clang and MS VC++ (see https://learn.microsoft.com/en-us/cpp/parallel/openmp/openmp-simd), and enabling Auto-Vectorizer Reporting will help identify loops that can be optimized. This is done in CMakeLists.txt:

# Add OpenMP experimental flags depending on compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    target_compile_options(thot_lib PUBLIC -fopenmp -fopenmp-experimental)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    target_compile_options(thot_lib PUBLIC -fopenmp)
elseif (MSVC)
    target_compile_options(thot_lib PUBLIC /openmp:experimental /Qvec-report:2)
endif()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions