MKL problems running vslsCorrExec1D, cross correlation.

MKL problems running vslsCorrExec1D, cross correlation.

I am having problems running the vslsCorrExec1D routine in MKL 8.0.
I am able to run the corresponding convolution vslsConvExec1D, but when I'm converting all "conv" to "corr" the function vslsCorrExec1D return status=-2911. Any suggestions?

A snippet of code follows below:

// Test Crosscorrelation
int const Nx = 4;
int const Nh = 4;
int const Nz = (2*Nx-1);

int iy0 = 0;
float a1[Nx];
float h1[Nh];
float z1[Nz];
for(int i=0;i a1[i] = i;
h1[i] = i;
}

// Convolution
// This is working
VSLConvTaskPtr task;
status = vslsConvNewTask1D(&task,VSL_CONV_MODE_AUTO,Nh,Nx,Nz);
std::cerr << "status= " << status << std::endl;
status = vslConvSetStart(task,&iy0);
std::cerr << "status= " << status << std::endl;
status = vslsConvExec1D(task,h1,1,a1,1,z1,1);
std::cerr << "status= " << status << std::endl;
status = vslConvDeleteTask(&task);
std::cerr << "status= " << status << std::endl;
for(int i=0;i std::cerr << z1[i] << std::endl;
}

// Cross Correlation
// Not working
VSLCorrTaskPtr task2;
status = vslsCorrNewTask1D(&task2,VSL_CORR_MODE_AUTO,Nh,Nx,Nz);
std::cerr << "status= " << status << std::endl;
status = vslCorrSetStart(task2,&iy0);
std::cerr << "status= " << status << std::endl;
status = vslsCorrExec1D(task2,h1,1,a1,1,z1,1);
std::cerr << "status= " << status << std::endl;
status = vslCorrDeleteTask(&task2);
std::cerr << "status= " << status << std::endl;
for(int i=0;i std::cerr << z1[i] << std::endl;
}

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Short answer: The problem is in the way you are using the iy0 parameter. To fix this issue, the value of iy0 should be reassigned to (Nh-1) before calculating correlation.

Todd

Message Edited by trosenqu on 10-13-2005 06:26 AM

Here is the somewhat longer, but more helpful response from the developer.

Mathematically, the operations of convolution and correlation assume different enumerations for elements of the output array. For convolution, the output is enumerated as w0, , w(Nh-1)+(Nx-1); and for correlation, the enumeration is w-(Nh-1), , wNx-1.

If the parameter iy0 is assigned to 0, for convolution this implies that the output array z1[] is fulfilled starting from the 0th element of the mathematical enumeration, i.e.:

z1[0]=w0, , z1[Nz-1]=wNz-1

For correlation, the parameter iy0 is usually assigned to (Nh-1); this again implies that z1[] is fulfilled starting from the beginning of the mathematical sequence:

z1[0]=w-(Nh-1), , z1[Nz-1]=wNx-1

The user could just omit the calls to the SetStart() functions to let the software adjusting the iy0 parameter automatically. By default, iy0 would be assigned to 0 for convolution, and to (Nh-1) for correlation.

Anyway, if iy0 is explicitly assigned by user and iy0>-(Nh-1), for the case of correlation this implies that z1[] must start from the middle of the mathematical output:

z1[0]=w0, , z[Nx-1]=wNx-1,

Unfortunately, mathematical results are not defined for z1[Nx], , z1[Nz-1] in this case; and the software signals about this problem that it cannot calculate z1[i] for i>Nx-1.

To fix this issue, the code snippet could be changed as shown in the attached file. Here, the value of iy0 is reassigned to (Nh-1) before calculating correlation.

Or, if the user intentionally assumed to fulfill the correlation output as z1[0]=w0, ; then the value of Nz should be reduced to Nx or to some less value in order to ensure that mathematical results would be defined for all z1[i] up to i=Nz-1.

Thanks!! This works perfectly!!

Leave a Comment

Please sign in to add a comment. Not a member? Join today