473,795 Members | 3,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1993
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************ *************** ***********@pyt hon.org>, 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
3279
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 with this problem. I am uncertain about what etiquette calls for, but more on that later. My Objective: I am trying to control the _VMWare Desktop_ application
1
4728
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. This is Python 2.5 on Linux. Here's what I have so far--if you comment out the memmove call (3 lines) it works as expected: # START #!/usr/local/bin/python2.5
7
7049
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 case basis"? \\\ For example, suppose sometimes I receive the value '\x03hi' + \x04bye' for the struct:
6
12952
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 I should declare the return type of the functions and read the fields. Any hint is appreciated. typedef struct { char *country_short; char *country_long;
1
2453
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 more information. None So I thought I'd try out pcre through ctypes, to recreate pcredemo.c in python. The c code is at:
3
11668
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, -a
1
1414
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. 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.
0
190
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 ctypes driver doing the same exact operations as the C++ test harness? If not, it may be exposing a bug in your code. I've had a few occasions when using SSE2 intrinsics where I had a bug in my loop such that I was going off the end of the array...
15
4669
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-------- #if defined(_M_CEE_PURE) #error ERROR: MM intrinsics not supported in the pure mode! #else
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.