[PATCH take 2] Emulate clock and other stubs on nvptx

Roger Sayle roger@nextmovesoftware.com
Tue Aug 24 16:48:44 GMT 2021


Alas, I'm having trouble with "git send-email", but hopefully the attached patch
generated by "git format-patch" is close enough.  Many thanks also for the
speedy locale fix.  This revised patch takes advantage of a (upcoming) __PTX_SM__
macro that I'm just about to push to GCC, that allows newlib's clock to use an
accurate timer on more recent GPUs.  This avoids the clock speed issue.

Thanks in advance.
Roger
--

-----Original Message-----
From: Corinna Vinschen <vinschen@redhat.com> 
Sent: 19 August 2021 11:22
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] Emulate clock and other stubs on nvptx

Hi Roger,

On Aug 18 17:43, Roger Sayle wrote:
> 
> Please be gentle, this is my first patch to newlib.
> 
> This patch to the libc/machine/nvptx port of newlib implements an 
> approximation of "clock" and provides some additional stub routines.
> These changes not only reduce the number of (link) failures in the GCC 
> testsuite when targeting nvptx-none, but also allow the NIST scimark4 
> benchmark to compile and run without modification.
> 
> newlib already contains support for backends to provide their own 
> clock implementations via -DCLOCK_PROVIDED.  That functionality is 
> used here to return an approximate elapsed time based on the NVidia 
> GPU's clock64 cycle counter.  Although not great, this is better than 
> the current behaviour of link error from the unresolved symbol 
> _times_r.
> 
> The other part of the patch is to add a small number of stub functions 
> to nvptx's misc.c.  Adding isatty, for example, resolves linking 
> problems in libc from the dependency in __smakebuf_r, and the sync 
> stub, for example, fixes the failure with GCC's
> testsuite/gfortran.dg/ISO_Fortran_binding_14.f90 [which simply tests 
> that gfortran can call a/any C function].
> 
> Hopefully, these changes are acceptable.  If so, if someone could 
> please commit

They are, but your patch submission is a bit weird and more work to apply than necessary.

Please commit your patches to your local git repo, including a nice commit message, create a git patch file via `git format-patch' and send it via `git send-email --to="newlib@..." to this mailing list.  Note that providing Makefile.in is nice, but you don't *have* to provide Makefile.in.  We'll regenerate that as required.

Another point:  Given the HW support for a monotonic clock tick, wouldn't it make more sense to implement clock_gettime() with support for CLOCK_REALTIME and CLOCK_MONOTONIC, and implement clock() by calling clock_gettime()?


Thanks,
Corinna

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nvptx.patch
Type: application/octet-stream
Size: 3229 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20210824/63afe26d/attachment.obj>


More information about the Newlib mailing list