<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:850754581;
mso-list-type:hybrid;
mso-list-template-ids:-1668778184 497315712 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\.\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Times New Roman",serif;
mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri;
mso-bidi-font-family:Calibri;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I see two issues:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="mso-list:Ignore">1.)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>The synchronous calls won’t execute the progress function once the they decide to sleep, so FI_PROGRESS_MANUAL does not work. This is absolutely true in util_cq, but not completely so in util_cntr since it sleeps in 50 ms intervals,
but the 50 ms would be an unacceptable latency in any real use. Using the cntr wait loop as an example:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-family:"Courier New"">do {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> cntr->progress(cntr);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> if (threshold <= ofi_atomic_get64(&cntr->cnt))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> return FI_SUCCESS;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> if (errcnt != ofi_atomic_get64(&cntr->err))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> return -FI_EAVAIL;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> if (ofi_adjust_timeout(endtime, &timeout))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> return -FI_ETIMEDOUT;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> /*<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * Temporary work-around to avoid a thread hanging in underlying<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * epoll_wait called from fi_wait. This can happen if one thread<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * updates the counter, another thread reads it (thereby resetting<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * cntr signal fd) and the current thread is about to wait. The<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * current thread would never wake up and doesn't know the counter<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * has been updated. Fix it by checking counter state every now<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * and then instead of waiting for a longer period. This does<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> * have the overhead of threads waking up unnecessarily.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> */
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> timeout_quantum = (timeout < 0 ? OFI_TIMEOUT_QUANTUM_MS :
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> MIN(OFI_TIMEOUT_QUANTUM_MS, timeout));
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> ret = fi_wait(&cntr->wait->wait_fid, timeout_quantum);
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> } while (!ret || (ret == -FI_ETIMEDOUT &&
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> (timeout < 0 || timeout_quantum < timeout)));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in">Setting the timeout_quantum to 0 in the case cntr->domain->data_progress == FI_PROGRESS_MANUAL seems to be a quick fix, but it might be wiser to allow a wait function to be specified as part of the util_cntr/cq
and let it deal with this. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="mso-list:Ignore">2.)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>ofi_cq_read() only calls the progress function if the cq is empty or the count is zero.<o:p></o:p></p>
<p class="MsoListParagraph"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> if (ofi_cirque_isempty(cq->cirq) || !count) {<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> cq->cq_fastlock_release(&cq->cq_lock);<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> cq->progress(cq);<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> cq->cq_fastlock_acquire(&cq->cq_lock);<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> if (ofi_cirque_isempty(cq->cirq)) {<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> i = -FI_EAGAIN;<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> goto out;<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> }<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-family:"Courier New""> }<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">While I actually like idea of trying to reduce gratuitous progress calls, this caused some code I had to break. I was doing a fi_recv(FI_PEEK) and getting ENOMSG returned immediately in the cq, because the queue
was never empty, the progress function was never called and my loop hung indefinitely. I believe the progress function must be called unconditionally.
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in">The util_cntr code does not have this issue, progress is called unconditionally in ofi_cntr_read().<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">John Byrne<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>