Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

remark #869 and __declspec(cpu_dispatch(...))

matthieu_darbois
New Contributor III
674 Views

Hi,

when using __declspec(cpu_dispatch(...)) on a function, I get multiple remark #869 ("parameter ... was never referenced") which is useless because a function declared with __declspec(cpu_dispatch(...)) must have an empty body so, by definition, its parameters can't be referenced in the body of the function.

We get enough remarks and warning as it is, so it would be nice if that remark disappeared in next release of the compiler.

I use Intel Compiler 11.0.061

Regards,

Matthieu

7 Replies
JenniferJ
Moderator
674 Views
Could you post the code snippet?
The following code is copied from the 11.0 user's guide, it doesn't cause the remark.
__declspec(cpu_specific(pentium))
void array_sum1(int *result, int *a, int *b, size_t len)
{
for (; len > 0; len--)
*result++ = *a++ + *b++;
}

0 Kudos
matthieu_darbois
New Contributor III
674 Views

Hi,

what i mentioned appears on the dispatch function, not the specific one

[cpp]__declspec(cpu_dispatch(generic))
void array_sum(int *result, int *a, int *b, size_t len)
{
} 

__declspec(cpu_specific(generic))
void array_sum(int *result, int *a, int *b, size_t len)
{
for (; len > 0; len--)
*result++ = *a++ + *b++;
} [/cpp]

In the example above, the remark #869 only appears on the first function (the dispatch function). It's true that there's no reference on result, a, b and len but it's by definition. If the dispatch function made a reference to one of the argument (not empty body), this would lead to an error (and I verified this by mistake) which is the normal behaviour.

0 Kudos
JenniferJ
Moderator
674 Views
You should change the 1st one to declaration without the "{}" and move it to a .h file. There's no need to add "__declspec" to it in declaration.
0 Kudos
matthieu_darbois
New Contributor III
674 Views
You should change the 1st one to declaration without the "{}" and move it to a .h file. There's no need to add "__declspec" to it in declaration.

Hi Jennifer,

I think there's a misunderstanding here. It's not the declaration of the function which has an empty body, it's the dispatch function as stated in the reference manual of the compiler, in the section "Targeting IA-32 and Intel 64 Architecture Processors Manually".

Here is a copy-paste of the example of the manual with correction as the example given in the manual contained a few errors (I also added the _mm_empty() call to get rid of a warning but I think it's not necessary to call it in this example).

I've also added a main function so that you can just compile it. I had to set warning level to /W4 for the remark to appear.

[cpp]#include 
#include 

/* Pentium processor function does not use intrinsics
   to add two arrays. */
__declspec(cpu_specific(pentium))
void array_sum(int *result, int const *a, int const *b, size_t len)
{
  for (; len > 0; len--)
    *result++ = *a++ + *b++;
}

/* Implementation for a Pentium processor with MMX technology uses
   an MMX instruction intrinsic to add four elements simultaneously. */
__declspec(cpu_specific(pentium_MMX))
void array_sum(int *result, int const *a, int const *b, size_t len)

{
  __m64 *mmx_result = (__m64 *)result;
  __m64 const *mmx_a = (__m64 const *)a;
  __m64 const *mmx_b = (__m64 const *)b;
  for (; len > 1; len -= 2)
    *mmx_result++ = _mm_add_pi16(*mmx_a++, *mmx_b++);

  _mm_empty();
  /* The following code, which takes care of excess elements, is not
     needed if the array sizes passed are known to be multiples of fours. */
  result = (int*)mmx_result;
  a = (int const *)mmx_a;
  b = (int const *)mmx_b;
  for (; len > 0; len--)
    *result++ = *a++ + *b++;

}

__declspec(cpu_dispatch(pentium, pentium_MMX))
void array_sum(int *result, int const *a, int const *b, size_t len)
{
  /* Empty function body informs the compiler to generate the
     CPU-dispatch function listed in the cpu_dispatch clause. */
}

int main(int argc, char* argv[])
{
    static int a[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22};
    static int b[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22};
    static int result[23];

    array_sum(result, a, b, 23);
    printf("Result %d, %d, %d, ...", result[0], result[1], result[2]);
    getc(stdin);
	return 0;
}[/cpp]

Regards,

Matthieu

0 Kudos
levicki
Valued Contributor I
674 Views

Matthieu,

If you set warning level 4, the compiler will warn about unused arguments for every function. It is up to you to prevent the warning for the functions you are not interested in by using:

#pragma warning(disable : 969)

void test(int *a)

{

...

}

#pragma warning(default : 969)

I understand that you would like the compiler to be smart enough to not warn about seemingly unused parameters in the declaration of the dispatch function and I agree with that.

However, I see no way of proving that the arguments are used, because they are not referenced in the function -- without examining all versions of the dispatched function and confirming that the argument is really being used in all of them, the compiler cannot assume they are used and keep quiet.

You can file a feature request to Premier Support (https://premier.intel.com/), but I personally doubt you will see the fix implemented soon since you already have a workaround, and the issue isn't exactly a showstopper.

matthieu_darbois
New Contributor III
674 Views
Quoting - Igor Levicki

Matthieu,

If you set warning level 4, the compiler will warn about unused arguments for every function. It is up to you to prevent the warning for the functions you are not interested in by using:

#pragma warning(disable : 969)

void test(int *a)

{

...

}

#pragma warning(default : 969)

I understand that you would like the compiler to be smart enough to not warn about seemingly unused parameters in the declaration of the dispatch function and I agree with that.

However, I see no way of proving that the arguments are used, because they are not referenced in the function -- without examining all versions of the dispatched function and confirming that the argument is really being used in all of them, the compiler cannot assume they are used and keep quiet.

You can file a feature request to Premier Support (https://premier.intel.com/), but I personally doubt you will see the fix implemented soon since you already have a workaround, and the issue isn't exactly a showstopper.

I understand that this is really not a showstopper. However, I thought that it would have been nice not to have those remarks and that the compiler would just ignore this specific remark when applied to a function with __declspec(cpu_dispatch(...)). Furthermore, I think that you'd have sufficient number of remarks with the specific versions of the function if an argument really wasn't used.

I'll think of filing a feature request...

Thanks for your input,

Matthieu

0 Kudos
levicki
Valued Contributor I
674 Views

I understand that this is really not a showstopper. However, I thought that it would have been nice not to have those remarks and that the compiler would just ignore this specific remark when applied to a function with __declspec(cpu_dispatch(...)). Furthermore, I think that you'd have sufficient number of remarks with the specific versions of the function if an argument really wasn't used.

I'll think of filing a feature request...

Thanks for your input,

Matthieu

You are welcome, if you find my answers helpfull please do not forget to select them as the best answer and rate my posts.

0 Kudos
Reply