469,593 Members | 1,987 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,593 developers. It's quick & easy.

Re: problem using ctypes with MMX intrinsics

dcharno wrote:
Is it possible to use ctypes with a shared library which uses MMX/SSE
intrinsics? I can load the library and access functions inside it, but
I getting a seg fault when I hit one of the intrinsics. I'm wondering
if there might be some sort of stack alignment problem.

I am using gcc version 4.2.3 and Python 2.5.2 on Ubuntu 8.04.

Any suggestions would be helpful.
Well, stack alignment would be a problem with how the shared library gets
compiled, nothing to do with ctypes (I think). However, if you are passing in
arrays from ctypes, *they* may also be misaligned. Try to check the addresses of
the ctypes values you are passing in. I'm not entirely sure how to do that, though.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 15 '08 #1
2 1749
Robert Kern schrieb:
dcharno wrote:
>Is it possible to use ctypes with a shared library which uses MMX/SSE
intrinsics? I can load the library and access functions inside it,
but I getting a seg fault when I hit one of the intrinsics. I'm
wondering if there might be some sort of stack alignment problem.

I am using gcc version 4.2.3 and Python 2.5.2 on Ubuntu 8.04.

Any suggestions would be helpful.

Well, stack alignment would be a problem with how the shared library
gets compiled, nothing to do with ctypes (I think). However, if you are
passing in arrays from ctypes, *they* may also be misaligned. Try to
check the addresses of the ctypes values you are passing in. I'm not
entirely sure how to do that, though.
there is the addressof-function. If this is really the problem, it
should be possible to allocate data + margin (e.g. c_int-arrays), and
cast the proper aligned address via from_address.

Diez
Oct 15 '08 #2
In message <ma**************************************@python.o rg>, Robert
Kern wrote:
Try to check the addresses of the ctypes values you are passing in. I'm
not entirely sure how to do that, though.
Cast the address to an integer and print it out? I think the data needs to
be 16-byte-aligned, so in hex, the units digit of the address should always
be zero.
Oct 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by sjdevnull | last post: by
6 posts views Thread by Jack | last post: by
1 post views Thread by moreati | last post: by
3 posts views Thread by Andrew Lentvorski | last post: by
1 post views Thread by dcharno | last post: by
reply views Thread by Robert Kern | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.