<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Sure, thanks also for the quick reply.<br>
    </p>
    <p> Raúl</p>
    <div class="moz-cite-prefix">El 1/2/21 a las 19:10, Shilei Tian
      escribió:<br>
    </div>
    <blockquote type="cite"
      cite="mid:99643FAB-A648-4EEB-B59F-77C000F4E848@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Hi Raúl,
      <div class=""><br class="">
      </div>
      <div class="">This patch (<a
          href="https://reviews.llvm.org/D95798" class=""
          moz-do-not-send="true">https://reviews.llvm.org/D95798</a>)
        should fix the issue. Can I include your test into the repo?</div>
      <div class=""><br class="">
        <div class="">
          <div dir="auto" style="caret-color: rgb(0, 0, 0); color:
            rgb(0, 0, 0); letter-spacing: normal; text-align: start;
            text-indent: 0px; text-transform: none; white-space: normal;
            word-spacing: 0px; -webkit-text-stroke-width: 0px;
            text-decoration: none; word-wrap: break-word;
            -webkit-nbsp-mode: space; line-break: after-white-space;"
            class="">
            <div>Regards,<br class="">
              Shilei<br class="">
            </div>
          </div>
        </div>
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On Feb 1, 2021, at 12:31 PM, Shilei Tian <<a
                href="mailto:tianshilei1992@gmail.com" class=""
                moz-do-not-send="true">tianshilei1992@gmail.com</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <meta http-equiv="Content-Type" content="text/html;
                charset=UTF-8" class="">
              <div style="word-wrap: break-word; -webkit-nbsp-mode:
                space; line-break: after-white-space;" class="">Hi Raúl,
                <div class=""><br class="">
                </div>
                <div class="">Thanks for your report. I’ll fix it soon.</div>
                <div class=""><br class="">
                  <div class="">
                    <div dir="auto" style="caret-color: rgb(0, 0, 0);
                      letter-spacing: normal; text-align: start;
                      text-indent: 0px; text-transform: none;
                      white-space: normal; word-spacing: 0px;
                      -webkit-text-stroke-width: 0px; text-decoration:
                      none; word-wrap: break-word; -webkit-nbsp-mode:
                      space; line-break: after-white-space;" class="">
                      <div class="">Regards,<br class="">
                        Shilei<br class="">
                      </div>
                    </div>
                  </div>
                  <div style="" class=""><br class="">
                    <blockquote type="cite" class="">
                      <div class="">On Feb 1, 2021, at 3:48 AM, Raúl
                        Peñacoba Veigas via Openmp-dev <<a
                          href="mailto:openmp-dev@lists.llvm.org"
                          class="" moz-do-not-send="true">openmp-dev@lists.llvm.org</a>>
                        wrote:</div>
                      <br class="Apple-interchange-newline">
                      <div class="">
                        <div class="">Hi everyone,<br class="">
                          <br class="">
                          I've noticed in 9d64275a the behavior of
                          detached tasks has changed. From this commit
                          now the runtime does not taskwait the detached
                          task until completion. If I understand
                          correctly, detached tasks behave like a proxy
                          task, and proxy tasks are taskwaited until
                          completion.<br class="">
                          <br class="">
                          I attach test that creates a detached or proxy
                          task that performs a sleep to check that the
                          master thread stays in the taskwait.<br
                            class="">
                          <br class="">
                          // test.c<br class="">
                          <br class="">
                          #if !defined(DETACH) &&
                          !defined(PROXY)<br class="">
                          #error Use -DDETACH or -DPROXY to compile the
                          test<br class="">
                          #endif<br class="">
                          <br class="">
                          #include <stdio.h><br class="">
                          #include <pthread.h><br class="">
                          #include <omp.h><br class="">
                          #include <unistd.h><br class="">
                          <br class="">
                          // detached<br class="">
                          #define PTASK_FLAG_DETACHABLE 0x40<br class="">
                          // proxy<br class="">
                          #define PTASK_FLAG_PROXY 0x10<br class="">
                          <br class="">
                          // OpenMP RTL interfaces<br class="">
                          typedef long long kmp_int64;<br class="">
                          <br class="">
                          typedef struct ID {<br class="">
                            int reserved_1;<br class="">
                            int flags;<br class="">
                            int reserved_2;<br class="">
                            int reserved_3;<br class="">
                            char *psource;<br class="">
                          } id;<br class="">
                          <br class="">
                          // Compiler-generated code (emulation)<br
                            class="">
                          typedef struct ident {<br class="">
                            void* dummy; // not used in the library<br
                            class="">
                          } ident_t;<br class="">
                          <br class="">
                          typedef enum kmp_event_type_t {<br class="">
                            KMP_EVENT_UNINITIALIZED = 0,<br class="">
                            KMP_EVENT_ALLOW_COMPLETION = 1<br class="">
                          } kmp_event_type_t;<br class="">
                          <br class="">
                          typedef struct {<br class="">
                            kmp_event_type_t type;<br class="">
                            union {<br class="">
                              void *task;<br class="">
                            } ed;<br class="">
                          } kmp_event_t;<br class="">
                          <br class="">
                          typedef struct shar { // shareds used in the
                          task<br class="">
                          } *pshareds;<br class="">
                          <br class="">
                          typedef struct task {<br class="">
                            pshareds shareds;<br class="">
                            int(*routine)(int,struct task*);<br class="">
                            int part_id;<br class="">
                          // void *destructor_thunk; // optional, needs
                          flag setting if provided<br class="">
                          // int priority; // optional, needs flag
                          setting if provided<br class="">
                          // ------------------------------<br class="">
                          // privates used in the task:<br class="">
                            omp_event_handle_t evt;<br class="">
                          } *ptask, kmp_task_t;<br class="">
                          <br class="">
                          typedef int(* task_entry_t)( int, ptask );<br
                            class="">
                          <br class="">
                          #ifdef __cplusplus<br class="">
                          extern "C" {<br class="">
                          #endif<br class="">
                          extern int  __kmpc_global_thread_num(void
                          *id_ref);<br class="">
                          extern int** __kmpc_omp_task_alloc(id *loc,
                          int gtid, int flags,<br class="">
                                                             size_t sz,
                          size_t shar, task_entry_t rtn);<br class="">
                          extern int __kmpc_omp_task(id *loc, kmp_int64
                          gtid, kmp_task_t *task);<br class="">
                          extern void __kmpc_proxy_task_completed_ooo (
                          kmp_task_t *ptask );<br class="">
                          extern omp_event_handle_t
                          __kmpc_task_allow_completion_event(<br
                            class="">
                                                        ident_t
                          *loc_ref, int gtid, kmp_task_t *task);<br
                            class="">
                          #ifdef __cplusplus<br class="">
                          }<br class="">
                          #endif<br class="">
                          <br class="">
                          int volatile checker;<br class="">
                          <br class="">
                          void *target(void *task)<br class="">
                          {<br class="">
                              sleep( 3 );<br class="">
                              checker = 1;<br class="">
                          #ifdef DETACH<br class="">
                              omp_fulfill_event(((ptask)task)->evt);<br
                            class="">
                          #endif<br class="">
                          #ifdef PROXY<br class="">
                             
                          __kmpc_proxy_task_completed_ooo((ptask)task);<br
                            class="">
                          #endif<br class="">
                              return NULL;<br class="">
                          }<br class="">
                          <br class="">
                          pthread_t target_thread;<br class="">
                          <br class="">
                          // User's code<br class="">
                          int task_entry(int gtid, ptask task)<br
                            class="">
                          {<br class="">
                              pthread_create(&target_thread, NULL,
                          &target, task);<br class="">
                              return 0;<br class="">
                          }<br class="">
                          <br class="">
                          int main() {<br class="">
                            int gtid = __kmpc_global_thread_num(NULL);<br
                            class="">
                            ptask task;<br class="">
                            checker = 0;<br class="">
                            omp_event_handle_t evt;<br class="">
                          /*<br class="">
                            #pragma omp task detach(evt)<br class="">
                            {}<br class="">
                          */<br class="">
                          #ifdef DETACH<br class="">
                            printf("detaching...\n");<br class="">
                            task =
                          (ptask)__kmpc_omp_task_alloc(NULL,gtid,PTASK_FLAG_DETACHABLE,<br
                            class="">
                                              sizeof(struct
                          task),sizeof(struct shar),&task_entry);<br
                            class="">
                            evt =
                          (omp_event_handle_t)__kmpc_task_allow_completion_event(NULL,gtid,task);<br
                            class="">
                            task->evt = evt;<br class="">
                          #endif<br class="">
                          #ifdef PROXY<br class="">
                            printf("proxifying...\n");<br class="">
                            task =
                          (ptask)__kmpc_omp_task_alloc(NULL,gtid,PTASK_FLAG_PROXY,<br
                            class="">
                                              sizeof(struct
                          task),sizeof(struct shar),&task_entry);<br
                            class="">
                          #endif<br class="">
                            __kmpc_omp_task(NULL, gtid, task);<br
                            class="">
                            #pragma omp taskwait<br class="">
                          <br class="">
                            // check results<br class="">
                            if (checker == 1) {<br class="">
                              printf("passed\n");<br class="">
                              return 0;<br class="">
                            } else {<br class="">
                              printf("failed\n");<br class="">
                              return 1;<br class="">
                            }<br class="">
                          }<br class="">
                          <br class="">
                          // end test.c<br class="">
                          <br class="">
                          To use detached or proxy task use -DDETACH or
                          -DPROXY in the compilation line.<br class="">
                          <br class="">
                          The source line that is performing that
                          behavior is <a
href="https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L1274"
                            class="" moz-do-not-send="true">https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp_tasking.cpp#L1274</a>
                          . Previously the code was <a
href="https://github.com/llvm/llvm-project/blob/357eea6e8bf78a822b8d3a6fe3bc6f85fee66a3e/openmp/runtime/src/kmp_tasking.cpp#L1236"
                            class="" moz-do-not-send="true">https://github.com/llvm/llvm-project/blob/357eea6e8bf78a822b8d3a6fe3bc6f85fee66a3e/openmp/runtime/src/kmp_tasking.cpp#L1236</a>
                          .<br class="">
                          <br class="">
                          Regards,<br class="">
                          <br class="">
                          Raúl<br class="">
                          <br class="">
                          <br class="">
                          <br class="">
                          <a href="http://bsc.es/disclaimer" class=""
                            moz-do-not-send="true">http://bsc.es/disclaimer</a><br
                            class="">
_______________________________________________<br class="">
                          Openmp-dev mailing list<br class="">
                          <a href="mailto:Openmp-dev@lists.llvm.org"
                            class="" moz-do-not-send="true">Openmp-dev@lists.llvm.org</a><br
                            class="">
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a><br class="">
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br class="">
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
  
<br>
<br>
WARNING / LEGAL TEXT: This message is intended only for the use of the
individual or entity to which it is addressed and may contain
information which is privileged, confidential, proprietary, or exempt
from disclosure under applicable law. If you are not the intended
recipient or the person responsible for delivering the message to the
intended recipient, you are strictly prohibited from disclosing,
distributing, copying, or in any way using this message. If you have
received this communication in error, please notify the sender and
destroy and delete any copies you may have received.
<br><br>
<a href="http://www.bsc.es/disclaimer">http://www.bsc.es/disclaimer</a>
<br>
</body>
</html>