Community
cancel
Showing results for 
Search instead for 
Did you mean: 
llevrel
Beginner
56 Views

Problems with errno when mixing VSL and VML calls

Hi,

I've just found that testing the value of errno to check for errors in VML calls is not reliable, because other MKL routines do return without errors yet leaving errno!=0.

Some routines, like MKL_malloc or VSL calls, have a return value which can be tested. One can then implement a (cumbersome) workaround by adding something like:
if(return_code==0) errno=0;
after each call to a non-VML routine. However, this cannot be done with (e.g.) MKL_free (and I have some evidence that it does change errno sometimes, but I'm still running some tests to be sure).

Did I miss something evident? Otherwise, is there a standard way to submit feature requests?

Cheers.
0 Kudos
4 Replies
barragan_villanueva_
Valued Contributor I
56 Views

Hi,

MKL functions (except VSL/...) are not set/change directly 'errno'. But 'erno'can beset indirectly.
For example, in caseof MKL_malloc failure, the return`errno' is setto `ENOMEM'.
You know, MKL_free must not change 'errno'.

BTW, what feature do you need related to errno or error-handling in MKL?

Please contact http://premier.intel.com for your suggestions.
llevrel
Beginner
56 Views

In my current test I've got one call to MKL_malloc which returned correctly (non-NULL pointer) but set errno to 12. In previous tests I also got VSL routines returning status==0 but errno==12.

I understand that I must not rely on errno to check errors in MKL_malloc or VSL routines. But a non-zero errno then goes through successful VML calls untouched. E.g.
status=vslcCorrExec1D(...);
// here status==0 and errno==12
vcAdd(...):
// vcAdd is successful but errno is still 12

Since VML routines have no return code, I thought I'd use errno as a way to check for errors and abort:
if(errno) {perror("name of routine");abort();}
Finally I found the Ref Manual mentions a global variable vmlErrStatus. I'd rather use it, but is it thread-safe?

Thanks for your help.
Andrey_G_Intel2
Employee
56 Views

VML&VSL are not set errno to 0 in case of successful call (no errors happened), but set errno in case of error happened. So, you can use your errors checking method if you clean errno before calls to VML&VSL.

Yes, all VML service functions, which are described in VML Error Diagnostics secrions, are thread safe.

Andrey

llevrel
Beginner
56 Views

Thanks to you two.
Reply