I write the following code
__m256d guess = _mm256_set1_pd(1.0);
__m256d x_vec = _mm256_set1_pd(x);
__m256d two_vec = _mm256_set1_pd(2.0);
__m256d neg_one_vec = _mm256_set1_pd(-1.0);
for (int j = 0; j < iterations; ++j) {
__m256d x_times_guess = _mm256_mul_pd(x_vec, guess);
__m256d two_minus_x_times_guess = _mm256_fmadd_pd(neg_one_vec, x_times_guess, two_vec);
guess = _mm256_mul_pd(guess, two_minus_x_times_guess);
}
double result;
_mm256_storeu_pd(&result, guess);
and compile it with g++ command
g++ --std=c++11 -O2 -mavx reciprocal.cpp
and get the error ‘_mm256_fmadd_pd’ was not declared in this scope
. But I am able to use other functions such as _mm256_set1_pd
and _mm256_mul_pd
I have included
#include <immintrin.h>
and checked my cpu-info. It is a Core(TM) i7-7800X and supports avx, avx2, avx512f and avx512dq.
Here’s the flags of my cpu:
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single ssbd mba rsb_ctxsw ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities