Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Diagnostic 15512: Not enough return values of vector variant 'xxxx' of function 'xxxx' at position <val>

$
0
0

Cause:
This diagnostic is emitted by Intel(R) C++ Compiler 15.0 and above.This example uses User implemented vector variant of the function. Traditionally the vector variant of the user defined​ function is created by the compiler using __attribute__((vector)) with relevant clauses. Here the developer can provide target certain processors by providing the intrinsics implementation which targets those processor architecture. In this example, we create a vector variant of the scalar function MyMax() and target the vector variant for core i7 processor SSE4.2 architecture. This error pops up because the vector variant of the function's return type is void when the corresponding scalar version of the function returns float.

Examples:

#include <immintrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NN 1021
//__declspec(vector)
__declspec(noinline)
float MyMax(float* a, int b)
{
  return *a + b;
}
__declspec(vector_variant(implements(MyMax(float* a, int b)), linear(a),
                          vectorlength(4), processor(core_i7_sse4_2)))
void MyMaxVec(float* v_a, __m128i v_b)
{
  *((__m128*)v_a) = _mm_add_ps(*((__m128*)v_a), _mm_cvtepi32_ps(v_b));
}

$ icpc user_f1_2.c -c -qopt-report2 -qopt-report-phase=vec -qopt-report-file=stderr
error #15512: Not enough return values of vector variant '_Z8MyMaxVecPf7__m128i' of function '_Z5MyMaxPfi' at position 0.
compilation aborted for user_f1_2.c (code 1)
 

Resolution:

By changing the return type of vector variant of MyMax from void to __m128 and adding the return statement which returns the vector value helps the compiler generate the vector function here.

#include <immintrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NN 1021
//__declspec(vector)
__declspec(noinline)
float MyMax(float* a, int b)
{
  return *a + b;
}
__declspec(vector_variant(implements(MyMax(float* a, int b)), linear(a),
                          vectorlength(4), processor(core_i7_sse4_2)))
__m128 MyMaxVec(float* v_a, __m128i v_b)
{
  *((__m128*)v_a) = _mm_add_ps(*((__m128*)v_a), _mm_cvtepi32_ps(v_b));
  return (*((__m128*)v_a));
}

Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>