[Openmp-commits] [PATCH] D45528: [OpenMP] Remove compilation warning when using clang to compile bc files.

Guansong Zhang via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Apr 13 14:49:35 PDT 2018


guansong added a comment.

In https://reviews.llvm.org/D45528#1067520, @grokos wrote:

> In https://reviews.llvm.org/D45528#1067487, @guansong wrote:
>
> > update as suggested (except PRId64)
>
>
> Isn't `PRId64` working?


I did not find any usage of it on the device side. Not confident on using it. We can remove the warning first, and improve the format later?



================
Comment at: libomptarget/deviceRTLs/nvptx/src/counter_groupi.h:48
 INLINE void omptarget_nvptx_CounterGroup::Complete(Counter &priv, Counter n) {
-  PRINT(LD_SYNCD, "complete priv counter 0x%llx with val %lld->%lld (+%d)\n",
+  PRINT(LD_SYNCD, "complete priv counter 0x%llx with val %lld->%lld (+%lld)\n",
         P64(&priv), P64(priv), P64(priv + n), n);
----------------
grokos wrote:
> The `P64` macro casts its argument to an `unsigned long long`. Use `%llu` instead of `%lld`.
Ok, will also update the other two lld to llu. 


================
Comment at: libomptarget/deviceRTLs/nvptx/src/libcall.cu:195
                 "task descr %s %d: %s, in par %d, dyn %d, rt sched %d,"
-                " chunk %lld; tid %d, tnum %d, nthreads %d\n",
+                " chunk %lu; tid %d, tnum %d, nthreads %d\n",
                 "ancestor", steps,
----------------
grokos wrote:
> Chunk is defined as `unsigned long long`, shouldn't the modifier be `%llu`?
sure


================
Comment at: libomptarget/deviceRTLs/nvptx/src/libcall.cu:264
     currTaskDescr->RuntimeChunkSize() = modifier;
-    PRINT(LD_IOD, "omp_set_schedule did set sched %d & modif %d\n",
+    PRINT(LD_IOD, "omp_set_schedule did set sched %d & modif %lu\n",
           (int)currTaskDescr->GetRuntimeSched(),
----------------
grokos wrote:
> Same here, `%llu`?
Yes


================
Comment at: libomptarget/deviceRTLs/nvptx/src/loop.cu:304
       PRINT(LD_LOOP,
-            "dispatch init (static chunk) : num threads = %d, ub = %lld,"
+            "dispatch init (static chunk) : num threads = %d, ub = %ld,"
             "next lower bound = %lld, stride = %lld\n",
----------------
grokos wrote:
> For consistency with the rest of libomptarget, use the `PRId64` macro to print an `int64_t`:
> ```
> "dispatch init (static chunk) : num threads = %d, ub = %" PRId64 ","
> ```
Not sure what is this. I can not find this PRId64 example. 


================
Comment at: libomptarget/deviceRTLs/nvptx/src/supporti.h:180-181
   void *ptr = malloc(size);
-  PRINT(LD_MEM, "malloc data of size %d for %s: 0x%llx\n", size, msg, P64(ptr));
-  ASSERT(LT_SAFETY, ptr, "failed to allocate %d bytes for %s\n", size, msg);
+  PRINT(LD_MEM, "malloc data of size %ld for %s: 0x%llx\n", size, msg, P64(ptr));
+  ASSERT(LT_SAFETY, ptr, "failed to allocate %ld bytes for %s\n", size, msg);
   return ptr;
----------------
grokos wrote:
> `size_t` can be printed in a portable way with the `%zu` modifier. For the nvptx RTL this is not a problem, but in general `size_t` is not guaranteed to be a long int, so usage of `%zu` is preferred. This is what we use in the rest of libomptarget. Can you use `%zu` here as well for consistency?
sure.


https://reviews.llvm.org/D45528





More information about the Openmp-commits mailing list