Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 22 May 2011 07:39:08 -0500 From: Pete Becker Organization: Roundhouse Consulting, Ltd. Newsgroups: comp.lang.c++ Date: Sun, 22 May 2011 08:39:08 -0400 Message-ID: <2011052208390816587-pete@versatilecodingcom> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Optimization problem User-Agent: Unison/2.1.4 Lines: 41 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-v29UY7BUw9PPG+YGtWNqcwLaL2NegoS9N2mWwg9jzbmbgySLvS7Lj/g894V1CIVq2dpxRjxuxnRlN7z!AHOA5oe3o1cA5kZI2B1BXierMnYzWaUoGNhcF0e/u2W0ZhY8erv2nnBrE6cJMIMhtk55Zfgw X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3084 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:5334 On 2011-05-22 04:47:20 -0400, hamze said: > On May 22, 12:25 pm, Joshua Maurice wrote: >> On May 21, 11:29 pm, hamze wrote: >> >>> I have a special device in my system, I must work with it in this >>> manner that : write 4 bytes and read 3 bytes, >>> this device has no reset, so if one of reads or writes miss, from that >>> time device will not work correctly because order of writes and reads >>> are missed. >> >>> this device works right when optimization is off, but when I turn it >>> on it stop working properly in my code. >>> some time i did not use one of its read value, so I think optimization >>> remove it and order of read and writes are missed. >>> how can I solve this problem ? >>> I also test this solution that I defined an asm valotile ( ) and put >>> all reads and write inside it but still turning optimization on >>> corrupt my program result. >> >> From what I've heard in this group, volatile alone is insufficient for >> correct MMIO (memory mapped IO) on most systems. I would suggest >> looking at the docs for your implementation to see what it says about >> correct MMIO. You could also look at the output assembly to see if it >> is indeed not doing as you want. > > thanks alot, you gave me a valuable clue, > I know what is my hardware correct order of MMIO, but I dont know how > to make compiler know about it and force compile not to REORDER my > code. Since there's no code here, just a bunch of hand-waving, it's impossible to say definitively what's going on. But the compiler is not allowed to reorder or combine accesses to volatile objects. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book)