Skip to content

Commit

Permalink
Merge pull request #122 from outbrain/handle-fma-instruction
Browse files Browse the repository at this point in the history
Provide separate instructions in the case that FMA is not present
  • Loading branch information
ggaspersic authored Oct 12, 2023
2 parents fc2a416 + 9112912 commit d433efa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/block_ffm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,20 @@ unsafe fn prepare_contra_field_without_feature_value(
}

#[inline(always)]
#[cfg(not(target_feature = "fma"))]
unsafe fn prepare_contra_field_with_feature_value(
contra_fields_ptr: *mut f32,
ffm_weights_ptr: *const f32,
feature_value: __m128,
) {
let contra_fields = _mm_loadu_ps(contra_fields_ptr);
let ffm_weights = _mm_loadu_ps(ffm_weights_ptr);
let acc = _mm_add_ps(_mm_mul_ps(ffm_weights, feature_value), contra_fields);
_mm_storeu_ps(contra_fields_ptr, acc);
}

#[inline(always)]
#[cfg(target_feature = "fma")]
unsafe fn prepare_contra_field_with_feature_value(
contra_fields_ptr: *mut f32,
ffm_weights_ptr: *const f32,
Expand Down

0 comments on commit d433efa

Please sign in to comment.