473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 1966
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
1
by: sjdevnull | last post by:
Hey, I'm trying to wrap GNU readline with ctypes (the Python readline library doesn't support the callback interface), but I can't figure out how to set values to a variable inside the library. ...
7
by: p.lavarre | last post by:
How do I vary the byte offset of a field of a ctypes.Structure? How do I "use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by...
6
by: Jack | last post by:
I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how...
1
by: moreati | last post by:
Recently I discovered the re module doesn't support POSIX character classes: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for...
3
by: Andrew Lentvorski | last post by:
Basically, I'd like to use the ctypes module as a much more descriptive "struct" module. Is there a way to take a ctypes.Structure-based class and convert it to/from a binary string? Thanks,...
1
by: dcharno | last post by:
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....
0
by: Robert Kern | last post by:
dcharno wrote: Hmm. Okay. Start your program under gdb, find what data it's crashing on, check the alignment on it, and if it's misaligned, figure out where that data is coming from. Is the...
15
by: Anna Smidt | last post by:
Sorry, I have a question again: I am trying to debug/ release a CLR application (that uses the FrameWork). No when I try to compile it, it stops in this line in -------mmintrin.h-------- ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.