public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "Roger Sayle" <roger@nextmovesoftware.com>
To: <joel@rtems.org>
Cc: "'Newlib'" <newlib@sourceware.org>
Subject: RE: [PATCH] Emulate clock and other stubs on nvptx
Date: Thu, 19 Aug 2021 14:57:09 +0100	[thread overview]
Message-ID: <023001d79502$1d2b5010$5781f030$@nextmovesoftware.com> (raw)
In-Reply-To: <CAF9ehCUeBBS9Nv_B==bRRY8Gt9d8xJWXKZGVr2Oz2yhdRxMozA@mail.gmail.com>

 

Hi Joel,

 

The nvptx-none target doesn’t have an OS, a run-time nor a BIOS.

The only reason that clock may be emulated, is that the hardware has

a register containing the cycle count.  Pretty much the only function

provided is _vprintf, and the entire newlib-cygwin port builds off

of that.  Hence, newlib + the libc/machine/nvptx directory is the

entire operating system.

 

See https://sourceware.org/legacy-ml/newlib/2018/msg00299.html

 

Cheers,

Roger

--

 

From: Joel Sherrill <joel@rtems.org> 
Sent: 19 August 2021 13:59
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: Newlib <newlib@sourceware.org>
Subject: Re: [PATCH] Emulate clock and other stubs on nvptx

 

Should these be in a machine directory or a libgloss directory? If you ran a different run-time/OS on the CPU, at least some of these wouldn't make sense to be there. 

 

--joel

 

On Wed, Aug 18, 2021, 11:43 AM Roger Sayle <roger@nextmovesoftware.com <mailto:roger@nextmovesoftware.com> > 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
them for me that would be much appreciated (as I don't have repository
access).
Likewise, these changes should be obvious enough to not require a copyright
assignment, but to avoid any objections, I'm happy to put them in the public
domain.

2021-08-18  Roger Sayle  <roger@nextmovesoftware.com>

newlib/
        configure.host: Add -DCLOCK_PROVIDED to newlib_cflags on nvptx*.

newlib/libc/machine/nvptx
        Makefile.am: Add clock.c to lib_a_SOURCES.
        clock.c: New source file to implement/approximate clock().
        misc.c: Add stubs for fstat, isatty, open, sync and unlink.
        Makefile.in: Regenerate.

Many thanks in advance,
Roger
--
Roger Sayle
NextMove Software Limited
Cambridge, UK


      reply	other threads:[~2021-08-19 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 16:43 Roger Sayle
2021-08-19 10:22 ` Corinna Vinschen
2021-08-19 10:34   ` Corinna Vinschen
2021-08-19 10:45     ` [Fwd: Re: [PATCH] Emulate clock and other stubs on nvptx] Yago Rubio
2021-08-19 12:59 ` [PATCH] Emulate clock and other stubs on nvptx Joel Sherrill
2021-08-19 13:57   ` Roger Sayle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='023001d79502$1d2b5010$5781f030$@nextmovesoftware.com' \
    --to=roger@nextmovesoftware.com \
    --cc=joel@rtems.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).