Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Results (of ippsSum) depends on the alignment

Marc_L_
Beginner
261 Views

Hello,

I am observing slightly different results when calling ippsSum_64f with the same numbers but in a differently aligned array; is it a bug or a documented behaviour ?

Thanks !

PS: Here is a simple C program that shows this phenomenon:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "ipp.h"

#define SIZE 1000
#define NB_TESTS 10

int main (void) {
  int alignment,test,k;
  double input1[SIZE], input2[SIZE+1];

  for (alignment = 0; alignment < 8; alignment ++) {
    int failed = 0;

    for (test = 0; test < NB_TESTS; test ++) {
      double r1, r2;
      double *p = (double *) (alignment + (char *)input2);

      for (k = 0; k < SIZE; k ++) {
        input1 =  (double)rand() / (double)RAND_MAX;
        p = input1;
      }

      ippsSum_64f(input1, SIZE, &r1);
      ippsSum_64f(p, SIZE, &r2);

      if (r1 != r2) {
        printf("[%d %% 8] diff = %e\n", alignment, r2 - r1);
        failed ++;
      }
    }
    printf("[%d %% 8] %d / %d tests failed\n", alignment, failed, NB_TESTS);
  }

  return 0;
}

When the alignment is "0 % 8", ippsSum returns the same result on both inputs but when it's non-zero the test some times succeeds, some times fails (with an error around 1e-13).

0 Kudos
2 Replies
Shaojuan_Z_Intel
Employee
261 Views

Hi Marc,

For floating point computation, there could be small epsilon difference in result, and that is expected for different memory alignment. Here is an article discusses about the variation https://software.intel.com/en-us/articles/getting-reproducible-results-with-intel-mkl. Although the article talks about MKL, the same rule applies to IPP. Hope this helps. Thanks!

0 Kudos
Marc_L_
Beginner
261 Views

Thank you for your reply !

 

0 Kudos
Reply