Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

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

Petros_Mamales

Beginner

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

04-01-2012
01:37 PM

254 Views

MKL_INT vs size_t

I understand that the answer is 99.99% going to be negative, but for whatever it's worth:

Is there a way to use size_t instead of MKL_INT ? (like the way one can overwrite the MKL_Complex8 by std::complex

Any C/C++ structure that will describe some (sparse) matrix, will index with size_t rather than with int (and its variations). For non-sparse matrices where only the matrix dimension are the integers one uses, things are largely OK.

But for the sparse compressed format matrices, there is always a danger that the size of the integer array elements will be casted erroneously.

(Not to mention all the warning messages the compiler will emit because of the missmatch).

Any suggestions? ideas/workarounds? Maybe an option in a future mkl release? (yes I can imagine the binary layout issue, but, maybe another little flag ? ;-)) )

TIA,

Petros

ps: although looking for a portable solution, using msvc2010 on win7 with 64bit builds.

Link Copied

15 Replies

Andrey_N_Intel

Employee

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

04-01-2012
11:21 PM

254 Views

Please, have a look at the article that describes use of Intel MKL in C++ applications.

In particular, it covers the topic ofMKL_INT and size_t data types. The article is available at http://software.intel.com/en-us/articles/use-of-intel-mkl-data-types-in-cc-applications/.

Please, let us know if this addresses your question.

Best,

Andrey

barragan_villanueva_

Valued Contributor I

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

04-01-2012
11:25 PM

254 Views

Please read the corresponding MKL article: http://software.intel.com/en-us/articles/use-of-intel-mkl-data-types-in-cc-applications/?wapkw=mkl_i...

Petros_Mamales

Beginner

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

04-02-2012
05:21 AM

254 Views

Hi Andrey/Victor,

Yes it does !! (was right to "gamble the 0.01% ;-)))

Thank you very much,

Petros

Yes it does !! (was right to "gamble the 0.01% ;-)))

Thank you very much,

Petros

Petros_Mamales

Beginner

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

04-02-2012
08:28 AM

254 Views

[/cpp] Hi Victor/Andrey,

I am afraid that then there are a few problems here..

Take for example the mkl_?csrdia (or any function that contains diagonal sparse format).

The distance vector (counting the distance from the diagonal) can have either sgn.

However defining MKL_INT as size_t does not accomodate for it !! There should be a different type for the

distance vector elements, in order that MKL_INT can be defined as size_t.

Also, converting from csr to dense is less than perfect as the above example shows.

If instead of :

[cpp]#define MKL_INT int [/cpp]I use:

[cpp]#define MKL_INT size_t [/cpp]I get the (very!!!) erroneous output.

What to do ?

Any workarounds?

TIA,

Petros

PS: Using mkl10.3.8 with vs2010 on win7

The 2 outputs:

int

1 0 1.1 0 0

0 2 0 0 0

3.1 0 3 3.14 0

0 0 0 4 2.17

0 0 5.1 0 5

vs. (size_t)

0 -6.27744e+066 -6.27744e+066 -6.27744e+066 -6.27744e+066

1.1 1 -6.27744e+066 2 -6.27744e+066

0 0 0 -6.27744e+066 -6.27744e+066

3.1 1 0 2 -6.27744e+066

0 0 0 0 0

mecej4

Black Belt

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

04-02-2012
06:28 PM

254 Views

One point that you may have overlooked is that redefining MKL_INT with a preprocessor

By using negative values for a variable declared to be of type

It is the user's responsibility to make a thorough analysis of such cases before redefining data types in Intel MKL.

SKost

Valued Contributor II

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

04-02-2012
07:27 PM

254 Views

I get the (very!!!) erroneous output.

What to do ?

Any workarounds?

TIA,

Petros

PS: Using mkl10.3.8 with vs2010 on win7

The 2 outputs:

int

1 0 1.1 0 0

0 2 0 0 0

3.1 0 3 3.14 0

0 0 0 4 2.17

0 0 5.1 0 5

vs. (size_t)

0 -6.27744e+066 -6.27744e+066 -6.27744e+066 -6.27744e+066

1.1 1 -6.27744e+066 2 -6.27744e+066

0 0 0 -6.27744e+066 -6.27744e+066

3.1 1 0 2 -6.27744e+066

0 0 0 0 0

What to do ?

Any workarounds?

TIA,

Petros

PS: Using mkl10.3.8 with vs2010 on win7

The 2 outputs:

int

1 0 1.1 0 0

0 2 0 0 0

3.1 0 3 3.14 0

0 0 0 4 2.17

0 0 5.1 0 5

vs. (size_t)

0 -6.27744e+066 -6.27744e+066 -6.27744e+066 -6.27744e+066

1.1 1 -6.27744e+066 2 -6.27744e+066

0 0 0 -6.27744e+066 -6.27744e+066

3.1 1 0 2 -6.27744e+066

0 0 0 0 0

Did you try toverify sizes of **MKL_INT** ( not re-defined with your macro! ) and **size_t**:

...

**printf**( "**MKL_INT**: %ld\n**size_t**: %ld\n", sizeof( **MKL_INT** ), sizeof( **size_t** ));

...

Petros_Mamales

Beginner

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

04-02-2012
09:19 PM

254 Views

Fair enough. But then, the suggestion of typedef-ing MKL_INT is really of no use, if not misleading.

There are other examples (csrmultcsr, is one of them), where no negative integers are used, and if one tries

to use size_t will get nonsense (wasted a few hours with it ).

I understand the binary layout issue - indicated it in my initial request, where I mentioned it was a far shot.

Thank you for your help,

Petros

Petros_Mamales

Beginner

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

04-02-2012
09:20 PM

254 Views

Thank you for the suggestion. My editor, informs me of the definition of the types.

However, it is a good think to have in mind.

Thank you, again,

Petros

SKost

Valued Contributor II

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

04-02-2012
09:50 PM

254 Views

Here areexamples of declarationsof '

...

#ifdef _WIN64

typedef unsigned __int64 size_t;

#else

typedefunsigned int size_t;

#endif

...

...

#if defined ( MKL_ILP64 )

#define MKL_INT long long int /* 64 bit integer for large arrays. */

#else

#define MKL_INT int /* 32 bit integer for arrays < 2^31-1 elements. */

#endif

...

If by some reason a32-bittype'

that is whythe output is wrong.

What are results of your verifications for '

Best regards,

Sergey

Petros_Mamales

Beginner

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

04-02-2012
11:15 PM

254 Views

When defining MKL_INT as int they are 4 (MKL_INT) and 8 (size_t) .

When MKL_INT is defined as size_t they are both 8.

Btw, can you please confirm that ddnscsr delivers a dense matrix in C-format (i.e. row-storage) ?

Thank you for all your help,

Petros

ps: Since the compressed sparse format uses arrays of integers, having ones with different element size than MKL_INT is a bad idea. Given this, it is hard to imagine a situation, for those matrices, where defining MKL as size_t would ever be safe.

Andrey_N_Intel

Employee

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

04-03-2012
01:18 AM

254 Views

MKL_INT data type is 8 byteswhen youuse Intel MKL inILP64 mode, and 4 bytes, otherwise (additional details about ILP64 and LP64 modes are available in Intel MKL User Guide, section "Using the ILP64 Interface vs. LP64 Interface").

size_t type is8 bytes for _WIN64, and4 bytes, otherwise(in my version of MSVS2008 the definition of the size_t is in crtdefs.h).

So, when mapping MKL_INTinto size_t on Intel 64 CPUs, please make sureto specify ILP64 modeby defining -DMKL_INT64 and link against Intel Math Kernel Library inILP64 mode (mkl_intel_ilp64.lib,... for static linking).

I took your example, modified it as described in the article

#define MKL_INT size_t

#include

...

and built it using the command

icl -DMKL_ILP64 testcase.cpp mkl_intel_ilp64.lib mkl_core.lib mkl_intel_thread.lib libiomp5md.lib

The output of the example is

1 0 1.1 0 0

0 2 0 0 0

3.1 0 3 3.14 0

0 0 0 4 2.17

0 0 5.1 0 5

I have the same outputwith native MKL_INT.Please, let me knowif this helps to resolve theissues on your side.

Answering another your question: ddnscsr converter does not deliver a dense matrix in C-format; it delivers the matrix in Fortran format (column-major storage) using0-based indexing scheme.

Please, feel free to ask more questions if any.

Thanks,

Andrey

Petros_Mamales

Beginner

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

04-03-2012
10:52 AM

254 Views

Thank you very much for your response.

In the example I enclosed, the indexing of gedata is done in the row-storage format (C-style) for the

dense matrix:

cout<

This rather looks like that it is in C-format. Am I missing something ?

For the rest, I have to delve into the user's guide, some more. Since I am writting plugg-ins for Excel/Python, I am not sure I can go LP64. Have to investigate.

At any rate, this integer mess turns out to be much more involved than I anticipated - and very likely for a good reason.

Thank you again for all your help,

Petros

Andrey_N_Intel

Employee

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

04-04-2012
05:46 AM

254 Views

I double-checkedyour question on the format with the engineer responsible for that functionality, andhe confirms that the converter can return a dense matrix in row-major (that is, C) format.

Can you please provide a bit more details, so we would be able to better understandthe reasons,why you can'tlink against ILP64 interface of Intel MKL (and which would help you to correctly re-define MKL_INT with size_t data type as described in myprevious post)?

Best,

Andrey

Petros_Mamales

Beginner

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

04-05-2012
09:38 AM

254 Views

Thank you for the reconfirmation.

As far as the LP64 issue, I did not say it is not possible. All I mean to say is that it requires further investigationon my part, that is not of the moment - as I commented I was expected the issue to be more light-weight.

Thank you very much for all your help,

Petros

Andrey_N_Intel

Employee

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

04-05-2012
10:54 PM

254 Views

Please, let us know the results of the investigations on your side when ready. It would help us to understand ifthe question of MKL_INT/size_t is properly addressed, or ourfurther helpis necessary.

Best,

Andrey

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