Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- Data fitting of vector-valued function

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

Highlighted

Mario_K_

Beginner

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

09-21-2015
02:12 AM

20 Views

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

Accepted Solutions

Highlighted

VictoriyaS_F_Intel

Employee

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

09-22-2015
03:28 AM

20 Views

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

5 Replies

Highlighted

VictoriyaS_F_Intel

Employee

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

09-21-2015
05:56 AM

20 Views

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

Highlighted

Mario_K_

Beginner

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

09-21-2015
06:17 AM

20 Views

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

Highlighted

VictoriyaS_F_Intel

Employee

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

09-22-2015
03:28 AM

21 Views

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

Highlighted

Mario_K_

Beginner

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

09-23-2015
12:26 AM

20 Views

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

Highlighted

VictoriyaS_F_Intel

Employee

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

09-23-2015
09:28 AM

20 Views

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

For more complete information about compiler optimizations, see our Optimization Notice.