- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am trying to run an example introduced by optimization manual(June 2013) on page 11-23, example 11-14. I tried to use a separate .s file to write the function, and a main.c file to do the main func. The code will only run correctly in debug mode. Please see attachment for my code. The cond_loop.c is actually cond_loop.s but the forum won't accept this kind of extension.
- icc main-2.c cond_loop.s -g Everything works fine.
- icc main-2.c cond_loop.s Segmentation Fault with failure to access array members at the end of the code.
After the function void cond_loop(const float *a, float *b, const float *c, const float *d, const float *e, const int length) returns, all the array pointers will be lost so I cannot access the old arrays anymore. This problem will only occur without -g compile option, meaning release code only bug. So I am not able to debug it. I did some research and it showed this is because in debug mode stack frame pointer will always be saved but in release mode this is not the case. I am not sure this is my problem and I don't really know how to solve the problem. I tried to push rbp and rsp but these won't help. Would anyone please help me look at it? Any advice is appreciated. Thank you all!
BTW: in attachment, cond_loop_c.c is the corresponding C version of the assembly and of course, this one works perfectly. And I am using Linux so it is X64 system V ABI. Thanks again.
Best
xiangpisai
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually it seems that there are two different functions: void cond_loop() and void cond_loop_c().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
>>...there are two different functions: void cond_loop() and void cond_loop_c()...
xiangpisai made a note that
...in attachment, cond_loop_c.c is the corresponding C version of the assembly...
Hmm...Might be my bad English. Actually I don't have a good idea what is const in assembly. In my assembly I didn't perform any check for that const. So I cannot tell the difference that in the C version of the code, whether using const or not will make any difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
[ Outputs ]
Test 1 - icl.exe /QxAVX /Od /MDd /D"_DEBUG" Test18.cpp
a[14] = 0.849280
c[14] = 0.657335
d[14] = 0.189015
e[14] = 0.729507
f[14] = 0.479530Test 2 - icl.exe /QxAVX /O1 /MD /D"NODEBUG" Test18.cpp
a[14] = 0.849280
c[14] = 0.657335
d[14] = 0.189015
e[14] = 0.729507
f[14] = 0.479530Test 3 - icl.exe /QxAVX /O2 /MD /D"NODEBUG" Test18.cpp
a[14] = 0.849280
c[14] = 0.657335
d[14] = 0.189015
e[14] = 0.729507
f[14] = 0.479530Test 4 - icl.exe /QxAVX /O3 /MD /D"NODEBUG" Test18.cpp
a[14] = 0.849280
c[14] = 0.657335
d[14] = 0.189015
e[14] = 0.729507
f[14] = 0.479530Note: Since a Seed is the same for all 4 tests results are identical.
Thanks for helping me test the code. I am also using a Dell Precision M4700. the only thing different is that I am using Linux---Debian Wheezy. I guess that's the main point why I am getting bugs. Anyway, after pushing corresponding registers to stack, things are working fine now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just wanted to point you to a great optimization resource:
http://agner.org/optimize/#manuals
Particulary this manual:
http://agner.org/optimize/optimizing_assembly.pdf
It explains Windows and Linux 32-bit and 64-bit ABI, calling conventions, name mangling, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Igor,
Thanks for the link. I've enjoyed Agner Fog's posts and web pages for many years and have considered him a valueable programming resource.
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »