Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Why ReadWithBarrier returns bool (current svn)
Why ReadWithBarrier returns bool (current svn) [message #15734] Tue, 06 May 2008 20:31 Go to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi, we have
template <class U>
inline bool ReadWithBarrier(const volatile U& b)
{
	volatile bool tmp = b;
	ReadMemoryBarrier();
	return tmp;
}


but use it as it would return an int too, like in

inline int  AtomicRead(const volatile Atomic& t)      { return ReadWithBarrier(t); }


So I would suggest to replace in ReadWithBarrier the bool with the U template parameter (in tmp var and return type).

Cheers, Hans.
Re: Why ReadWithBarrier returns bool (current svn) [message #15736 is a reply to message #15734] Tue, 06 May 2008 21:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
hans wrote on Tue, 06 May 2008 14:31

Hi, we have
template <class U>
inline bool ReadWithBarrier(const volatile U& b)
{
	volatile bool tmp = b;
	ReadMemoryBarrier();
	return tmp;
}


but use it as it would return an int too, like in

inline int  AtomicRead(const volatile Atomic& t)      { return ReadWithBarrier(t); }


So I would suggest to replace in ReadWithBarrier the bool with the U template parameter (in tmp var and return type).

Cheers, Hans.


Yes, already done. You caught us in the process Smile

BTW, final version removes second volatile too -> leads to more optimal but still correct code on both GCC and MSC (7.1, 8, 9).

Mirek
Re: Why ReadWithBarrier returns bool (current svn) [message #23107 is a reply to message #15736] Thu, 17 September 2009 11:19 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Thanks for good implementation and documentation in memory barrier that increase performance of execution in multi-core processors.
Ion Lupascu (tojocky)
Previous Topic: How to re-initialize random generator?
Next Topic: U++ core app as DLL: memory manager problems?
Goto Forum:
  


Current Time: Sat Apr 27 15:11:31 CEST 2024

Total time taken to generate the page: 0.03877 seconds