- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

I have a problem using the data fitting for a linear interpolation of a vector valued function. It seems that the format rhint is ignored by the function dfdInterpolate1D.

#include <iostream> #include "mkl.h" #define ALIGNMENT 64 int main(int argc, char** argv){ DFTaskPtr task; MKL_INT NX = 3; MKL_INT NY = 2; double* x = (double*)mkl_malloc(NX*sizeof(double), ALIGNMENT); double* y = (double*)mkl_malloc(NX*NY*sizeof(double), ALIGNMENT); x[0] = 0; x[1] = 1; x[2] = 2; /* y is 2 dimensional in col-major format (y(0)=(0;1), y(1)=(5;1), y(3)=(10;1)) */ y[0] = 0; y[1] = 1; y[2] = 5; y[3] = 1; y[4] = 10; y[5] = 1; MKL_INT yHint = DF_MATRIX_STORAGE_COLS; int status = dfdNewTask1D( &task, NX, x, DF_NO_HINT, NY, y, yHint); std::cout << "Status after dfdNewTask1D: " << status << std::endl; MKL_INT s_order = DF_PP_LINEAR; MKL_INT s_type = DF_PP_DEFAULT; MKL_INT ic_type = DF_NO_IC; double* ic = NULL; MKL_INT bc_type = DF_NO_BC; double* bc = NULL; double* scoeff = (double*)mkl_malloc(NY*(NX-1)* s_order * sizeof(double), ALIGNMENT); MKL_INT scoeffhint = DF_NO_HINT; status = dfdEditPPSpline1D( task, s_order, s_type, bc_type, bc, ic_type, ic, scoeff, scoeffhint ); std::cout << "Status after dfdEditPPSpline1D: " << status << std::endl; status = dfdConstruct1D( task, DF_PP_SPLINE, DF_METHOD_STD ); std::cout << "Status after dfdConstruct1D: " << status << std::endl; MKL_INT NSITE = 2; double* site = (double*)mkl_malloc(NSITE*sizeof(double), ALIGNMENT); site[0] = 0.5; site[1] = 1.5; MKL_INT sitehint = DF_NO_HINT; double* r = (double*)mkl_malloc(NSITE*NY*sizeof(double), ALIGNMENT); MKL_INT rhint = DF_MATRIX_STORAGE_COLS; MKL_INT ndorder = 1; MKL_INT dorder = 1; double* datahint = NULL; MKL_INT* cell = NULL; status = dfdInterpolate1D( task, DF_INTERP, DF_METHOD_PP, NSITE, site, sitehint, ndorder, &dorder, datahint, r, rhint, cell ); std::cout << "Status after dfdInterpolate1D: " << status << std::endl; status = dfDeleteTask( &task ); std::cout << "Status after dfDeleteTask: " << status << std::endl; /* Print output */ std::cout << "scoeff = ( "; for (int i = 0; i<NY*(NX-1)* s_order; i++){ std::cout << scoeff<< " "; } std::cout << ")" << std::endl; std::cout << "r = ( "; for (int i = 0; i<NSITE*NY; i++){ std::cout << r<< " "; } std::cout << ")" << std::endl; std::cout << "r_expected = ( 2.5 1 7.5 1 )" << std::endl; mkl_free(x); mkl_free(y); mkl_free(scoeff); mkl_free(site); mkl_free(r); return 0; }

**Output is (**Compiled on RedHat 64bit with parallel studio 2016**):**

Status after dfdNewTask1D: 0

Status after dfdEditPPSpline1D: 0

Status after dfdConstruct1D: 0

Status after dfdInterpolate1D: 0

Status after dfDeleteTask: 0

scoeff = ( 0 5 5 5 1 0 1 0 )

r = ( 2.5 7.5 1 1 )

r_expected = ( 2.5 1 7.5 1 )

RUN FINISHED; exit value 0; real time: 30ms; user: 0ms; system: 0ms

The output is written in row-major format to r instead of the choosen col-major format using rhint. Is there a problem with my code or is it not possible to get the expected format.

Thanks,

Mario

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Mario,

The results computed with Intel® MKL Data Fitting interpolation routines are currently packed in row-major format only.

To come up with a suggestion can you please help me better understand additional details behind your request/question? In particular, it would be useful to get a general idea about typical problem sizes such as dimension of vector valued function, number of interpolation sites and expected estimates (only values, or values and first order derivatives, etc) used in your application.

Additionally, how the column-major format you suggest is used in your subsequent computations? Do you need it to get additional performance benefit for your application, or it is used for usability reasons or something else?

Thank you,

Victoriya

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello Mario,

Generally, interpolation results computed with Data Fitting routines of Intel® MKL are represented as 3-dimensional array r of size NY x NSITE x ndorder. The results are packed in the following way:

- NSITE x ndorder array of interpolation results of the 1-st coordinate of vector-valued function;
- NSITE x ndorder array of interpolation results of the 2-nd coordinate of vector-valued function;
- ...

The flag rhint specifies how to pack the array of size NSITE x ndorder for each coordinate of the function. In your example ndorder=1, thus, the results in row-major format are the same as in column-major format.

Please have a look at the Intel® MKL documentation section that provides additional details on the storage format of interpolation results https://software.intel.com/en-us/node/522231 and let us know, if you have any additional questions on the Data Fitting component of the library.

Best regards,

Victoriya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello Victoriya,

thank you very much for your helpful comment.

Due to my frame I have an input function in major-column format and I also want to have this format after interpolation.

I could implement a function to convert from major-row to major-column by my own using cblas_dcopy

void majorRowToMajorCol(const unsigned int cGridSize, const unsigned int cDim, double* pSrc, double* pDst) { const int cIncrement = 1; const unsigned int cSize = cGridSize * cDim; double* pTemporary = mkl_alloc(cSize*sizeof(double), 64); cblas_dcopy(cSize, pSrc, cIncrement, pTemporary, cIncrement); for (int i = 0; i < cDim; i++){ cblas_dcopy(cGridSize, &pTemporary[i*cDim], cIncrement, &pDst, cDim); } mkl_free(pTemporary); }

but is there any other way which is more perfomant? Is there a suitable function in MKL?

Thanks,

Mario

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Mario,

The results computed with Intel® MKL Data Fitting interpolation routines are currently packed in row-major format only.

To come up with a suggestion can you please help me better understand additional details behind your request/question? In particular, it would be useful to get a general idea about typical problem sizes such as dimension of vector valued function, number of interpolation sites and expected estimates (only values, or values and first order derivatives, etc) used in your application.

Additionally, how the column-major format you suggest is used in your subsequent computations? Do you need it to get additional performance benefit for your application, or it is used for usability reasons or something else?

Thank you,

Victoriya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello Victoriya,

My typical problem is as follows. I have a complex valued 1-dimensional function F on grids with a size ~300.000. Now I want to compute the values of F on another grid of similar size by linear interpolation (no derivatives). The data fitting interpolation routines only support real valued functions, but one can interpret the complex function F as a real valued 2-dimensional function in major-column format by a cast i.e.

MKL_COMPLEX16* F = (MKL_COMPLEX16*)mkl_malloc(300000*sizeof(MKL_COMPLEX16), 64); double* realF = (double*)F; ... /* Data fitting result */ double* realFInterpolated = ...

But I want to cast this result back to 1-dimensional complex function i.e.

MKL_COMPLEX16* FInterpolated = (MKL_COMPLEX16*)realFInterpolated;

Here it is needed that realFInterpolated is also in major-column format. So I have to apply majorRowToMajorCol to realFInterpolated first.

Thanks,

Mario

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Mario,

Thank you for the explanation of Intel® MKL Data Fitting usage scenario in your application.This clarifies why having interpolation results in column-major order is necessary for you.

Currently the solution that you mentioned is a proper way to get the interpolation results in column-major format: you will need to re-pack the results after calling dfdInterpolate1D.

Can you please submit the feature request on support of the column-major format in the Data Fitting component of the library via Premier Support?

Thank you,

Victoriya

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page