This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] nvptx newlib port


On Fri, Apr 6, 2018 at 4:00 PM, Jeff Johnston <jjohnstn@redhat.com> wrote:

> Looks fine.  I might suggest you add a check in configure.host that issues
> an error or warning message if the elix-level is not set to 1 and
> --enable-global-io-streams is not set
> (if what you said above is required).  Other than that, I can check it in
> shortly.
>

Can those be forced in the configure magic and then not required
on the configure command line?

--joel

>
> -- Jeff J.
>
> On Fri, Mar 30, 2018 at 4:22 PM, Cesar Philippidis <cesar@codesourcery.com
> >
> wrote:
>
> > The attached patch adds a nvptx port to newlib. At present, the nvptx
> > target is comprised of a family of Nvidia GPUs with compute capability
> > sm_30 and above. The primary use of newlib on nvptx targets is for use
> > with OpenACC and OpenMP GPU offloading with GCC. For the past couple of
> > years, Mentor Graphics has been maintaining a newlib port for nvptx here
> > <https://github.com/MentorEmbedded/nvptx-newlib>.
> >
> > There are a couple of quirks with nvptx. Unlike traditional processors,
> > nvptx targets a text-based virtual instruction set known as PTX. For
> > starters, PTX does not support "circular references" where an array is
> > initialized with a value consisting of an offset to itself. This happens
> > in newlib/libc/reent/impure.c:impure_data. To get around that problem,
> > newlib needs to be configured with --enable-newlib-global-stdio-streams.
> > In practice that's fine because those stdio stream are only used for
> > standalone (i.e., non-GPU offloading) testing of GCC. The important
> > debug functions, printf, putchar and puts, have been remapped to PTX's
> > vprintf. Besides, our original port in github was initializing those
> > file streams to NULL.
> >
> > Because Nvidia GPUs are primarily used as offload accelerators, we
> > didn't spend much time emulating systems calls for the nvptx target. As
> > such, the nvptx target needs to be configured with
> > --enable-newlib-elix-level=1. However, I did have to implement some
> > dummy system calls write, exit, close, lseek and read. You may noticed
> > that this patch also overrides assert. That's because the PTX JIT chokes
> > with the call to fiprintf in assert_func. We also overrode the memory
> > management functions to utilize CUDA's malloc.
> >
> > Beyond that, the changes in this port are relatively non-invasive. I
> > compressed the patch because the regenerated configure scripts and
> > Makefiles made it roughly 260k. The nvptx port first appeared in GCC 5.
> > The instructions on how to build a GCC toolchain with nvptx offloading
> > can be found here <https://gcc.gnu.org/wiki/Offloading>. Just be sure to
> > configure newlib with the aforementioned
> > --enable-newlib-global-stdio-streams --enable-newlib-elix-level=1
> > options. We got around those options in the github version of newlib by
> > hacking the generic newlib code with nvptx-specific workarounds.
> >
> > Cesar
> >
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]