<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>Sorry :)</div><div>Attached !</div><div><br></div><div>BogDan.</div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> "thomas.senyk@nokia.com" &lt;thomas.senyk@nokia.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> bog_dan_ro@yahoo.com; necessitas-devel@kde.org<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, July 14, 2011 4:38 PM<br><b><span style="font-weight: bold;">Subject:</span></b> RE: atomics<br></font><br>The whitespaces and everything seams to be quite broken in
 your code-past :)<br><br>Could you create a projects, tar it and send it as attachment? This would help a lot and more people will be willing to run it :)<br><br>Greets<br>Thomas<br>________________________________________<br>From: ext BogDan [<a ymailto="mailto:bog_dan_ro@yahoo.com" href="mailto:bog_dan_ro@yahoo.com">bog_dan_ro@yahoo.com</a>]<br>Sent: Friday, July 08, 2011 3:33 PM<br>To: <a ymailto="mailto:necessitas-devel@kde.org" href="mailto:necessitas-devel@kde.org">necessitas-devel@kde.org</a><br>Subject: atomics<br><br>Hello Folks,<br><br>I've made a small application to test current available atomic implementations on android.<br>This are the results on a HTC sensation device:<br><br><br>Test 1<br>===============================<br>USING SMP safe ASM instructions<br>--------------------------------------------------------------------<br>Executing test_atomic_cmpxchg_ASM took 14714<br>Executing test_atomic_cmpxchg_GCC took 15685<br>Executing
 test_atomic_cmpxchg_Android took 8874<br>Executing test_atomic_inc_ASM took 14310<br>Executing test_atomic_inc_GCC took 16190<br>Executing test_atomic_inc_Android took 8351<br>===============================<br>Test 2<br>===============================<br>USING SMP unsafe ASM instructions<br>--------------------------------------------------------------------<br>Executing test_atomic_cmpxchg_ASM took 6904<br>Executing test_atomic_cmpxchg_GCC took 15814<br>Executing test_atomic_cmpxchg_Android took 8864<br>Executing test_atomic_inc_ASM took 6404<br>Executing test_atomic_inc_GCC took 16048<br>Executing test_atomic_inc_Android took 8198<br>===============================<br><br><br><br>And this is the
 code:<br><br>#include&lt;QDebug&gt;<br>#include&lt;QDateTime&gt;<br>#include&lt;sys/atomics.h&gt;<br>staticconstintLOOPS=100000000;<br>#defineSMP_SAFE<br>#ifdefSMP_SAFE<br>#definesmp_mb__asm____volatile__("dmb":::"memory")<br>#else<br>#definesmp_mb<br>#endif<br>intatomic_cmpxchg(int&amp;_q_value,intexpectedValue,intnewValue)<br>{<br>registerintresult;<br>smp_mb;<br>asmvolatile("0:\n"<br>"ldrex%[result],[%[_q_value]]\n"<br>"eors%[result],%[result],%[expectedValue]\n"<br>"itteq\n"<br>"strexeq%[result],%[newValue],[%[_q_value]]\n"<br>"teqeq%[result],#1\n"<br>"beq0b\n"<br>:[result]"=&amp;r"(result),<br>"+m"(_q_value)<br>:[expectedValue]"r"(expectedValue),<br>[newValue]"r"(newValue),<br>[_q_value]"r"(&amp;_q_value)<br>:"cc");<br>smp_mb;<br>returnresult==0;<br>}<br>voidtest_atomic_cmpxchg_ASM()<br>{<br>inttest=0;<br>for(inti=0;i&lt;LOOPS;i++)<br>{<br>atomic_cmpxchg(test,test,test+1);<br>}<br>qDebug()&lt;&lt;test;<br>}<br>voidtest_atomic_cmpxchg_GCC()<br>{<br
>inttest=0;<br>for(inti=0;i&lt;LOOPS;i++)<br>{<br>__sync_bool_compare_and_swap(&amp;test,test,test+1);<br>}<br>qDebug()&lt;&lt;test;<br>}<br>voidtest_atomic_cmpxchg_Android()<br>{<br>inttest=0;<br>for(inti=0;i&lt;LOOPS;i++)<br>{<br>__atomic_cmpxchg(test,test+1,&amp;test);<br>}<br>qDebug()&lt;&lt;test;<br>}<br>intatomic_inc(int&amp;_q_value,intvalueToAdd)<br>{<br>registerintoriginalValue;<br>registerintnewValue;<br>registerintresult;<br>smp_mb;<br>asmvolatile("0:\n"<br>"ldrex%[originalValue],[%[_q_value]]\n"<br>"add%[newValue],%[originalValue],%[valueToAdd]\n"<br>"strex%[result],%[newValue],[%[_q_value]]\n"<br>"teq%[result],#0\n"<br>"bne0b\n"<br>:[originalValue]"=&amp;r"(originalValue),<br>[newValue]"=&amp;r"(newValue),<br>[result]"=&amp;r"(result),<br>"+m"(_q_value)<br>:[valueToAdd]"r"(valueToAdd),<br>[_q_value]"r"(&amp;_q_value)<br>:"cc");<br>smp_mb;<br>returnoriginalValue;<br>}<br>voidtest_atomic_inc_ASM()<br>{<br>inttest=0;<br>intlast=0;<br>for(inti=
0;i&lt;LOOPS;i++)<br>{<br>last=atomic_inc(test,1);<br>}<br>qDebug()&lt;&lt;test&lt;&lt;last;<br>}<br>voidtest_atomic_inc_GCC()<br>{<br>inttest=0;<br>intlast=0;<br>for(inti=0;i&lt;LOOPS;i++)<br>{<br>last=__sync_fetch_and_add(&amp;test,1);<br>}<br>qDebug()&lt;&lt;test&lt;&lt;last;<br>}<br>voidtest_atomic_inc_Android()<br>{<br>inttest=0;<br>intlast=0;<br>for(inti=0;i&lt;LOOPS;i++)<br>{<br>last=__atomic_inc(&amp;test);<br>}<br>qDebug()&lt;&lt;test&lt;&lt;last;<br>}<br>voidtestAtomics()<br>{<br>#ifdefSMP_SAFE<br>qDebug()&lt;&lt;"USINGSMPsafeASMinstructions";<br>#else<br>qDebug()&lt;&lt;"USINGSMPunsafeASMinstructions";<br>#endif<br>QDateTimestart=QDateTime::currentDateTimeUtc();<br>test_atomic_cmpxchg_ASM();<br>qDebug()&lt;&lt;"Executingtest_atomic_cmpxchg_ASMtook"&lt;&lt;start.msecsTo(QDateTime::currentDateTimeUtc());<br>start=QDateTime::currentDateTimeUtc();<br>test_atomic_cmpxchg_GCC();<br>qDebug()&lt;&lt;"Executingtest_atomic_cmpxchg_GCCtook"&lt;&lt;start
.msecsTo(QDateTime::currentDateTimeUtc());<br>start=QDateTime::currentDateTimeUtc();<br>test_atomic_cmpxchg_Android();<br>qDebug()&lt;&lt;"Executingtest_atomic_cmpxchg_Androidtook"&lt;&lt;start.msecsTo(QDateTime::currentDateTimeUtc());<br>start=QDateTime::currentDateTimeUtc();<br>test_atomic_inc_ASM();<br>qDebug()&lt;&lt;"Executingtest_atomic_inc_ASMtook"&lt;&lt;start.msecsTo(QDateTime::currentDateTimeUtc());<br>start=QDateTime::currentDateTimeUtc();<br>test_atomic_inc_GCC();<br>qDebug()&lt;&lt;"Executingtest_atomic_inc_GCCtook"&lt;&lt;start.msecsTo(QDateTime::currentDateTimeUtc());<br>start=QDateTime::currentDateTimeUtc();<br>test_atomic_inc_Android();<br>qDebug()&lt;&lt;"Executingtest_atomic_inc_Androidtook"&lt;&lt;start.msecsTo(QDateTime::currentDateTimeUtc());<br>}<br><br><br>Please try this code on a different devices and post the results here.<br><br>Thanks,<br>BogDan.<br>_______________________________________________<br>Necessitas-devel mailing
 list<br><a ymailto="mailto:Necessitas-devel@kde.org" href="mailto:Necessitas-devel@kde.org">Necessitas-devel@kde.org</a><br><a href="https://mail.kde.org/mailman/listinfo/necessitas-devel" target="_blank">https://mail.kde.org/mailman/listinfo/necessitas-devel</a><br><br><br></div></div></blockquote></div></div></body></html>