Approximate math library

Approximate math library

can anyone offer any help with the AM library. i am apparantly not calling / linking to it properly. I can get correct answers but the program crashes almost immediately after the call. It is probably how the caller and callee are passing parameters, but i have tried linking to the AMaths.lib that came in the zip and i have tried adding the Amaths.c to the project (with fastcall,stdcall,and cdecl calling conventions). nothing works.
i am using 2002 with ICL++ 7.1
any help would be... uhm...helpful.

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

Although I'm not using this library yet, IIRC it provides vectorized versions of the functions and thus the arguments (quads) should be probably aligned to 16-byte boundaries

well, i have made much progress...
the following code will crash in ICL 7.1:

#include "AMaths.h"

__m128 a = _mm_set_ps(4.0f, 3.0f, 2.0f, 1.0f);
__m128 b;
float t[4];

b = am_sin_eps(a);
printf(" ans = {%f, %f, %f, %f}
char ch = getchar();
return 0;

I've looked at the assembly output files. the main program will pass the argument in the xmm0 register and the AMaths routine will read it from the register. but at the end of the am_sin_eps() routine it emits 'ret 16' as if the argument had been passed on the stack. if i change that to a simple 'ret ' the amaths routine works fine (so for the moment i'm just commenting out the 16 on all the routines i actually use).
I don't know if this is a problem with the compiler or the library ( perhaps the definition of __stdcall as relates to xmm registers has changed slightly..??). Or maybe i am still missing something and there is a compiler switch that makes it all work right as well.... it seems hard to believe that i'm the only person to try to use the amaths library with ICL7.1.

> float t[4];
> ...
> _mm_store_ps(t,b);

you have to ensure that "t" is aligned 16 :

_declspec(align(16)) float t[4];

(or use _mm_storeu_ps)

The problem is a change ein the calling conventions from version 5 to version 6/7 of the Intel compiler.

The AMaths library is still using the old calling conventions.

Attached are new Amaths.h and Amaths.c that will help.



I am a newcomer in the field of vector optimizationunder Windows.

After downloading the AM library (and the test app) from this website, I compiled it under VC6++ (not Intel compiler - and also on .NET 2003) and it crashed (on my AMD which supports MMX and SSE).

So, I replaced the main function of in MathTest.cpp with the source code below. Strange things happen: the function am_exp_ps is called about ten times, then col becomes suddenly huge.

Before learning more about assembly code in order to be able to debug this strange phenomenon, does anyone have an idea of what I did wrong???? Thanks.


int main()

long col; 

__m128 vx, vy;

vx = _mm_set_ps ((float) 0.1, (float) 3.2, (float) -5.6, (float) 1.4);

for (col = 0; col < 1000; col++)


	printf("col = 	%d
", col);

	vy = am_exp_ps(vx);


return 0;



I'm wondering if anyone ever figured this problem out? I'm seeing the same exact behavior.

I'm consistantly getting crashes when recompiling or linking against the AMLib. The only AMlib code that I've successfully executed is the precompiled test executable that came in the zip file, everything else crashes.. I've used ms vc++ 7.1 as well as 6.0 with the processor pack installed. Has anyone successfully used it without using the intel compiler?
Thanks much

Leave a Comment

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