This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Added device-side system call decls and related wrappers.
ClosedPublic

Authored by tra on Jan 27 2016, 10:28 AM.

Details

Reviewers
jlebar
Summary

Added declarations for system calls provided by PTX.
In addition to math functions, we also need to support std::malloc and std::free to match NVCC behavior.

Diff Detail

Event Timeline

tra updated this revision to Diff 46151.Jan 27 2016, 10:28 AM
tra retitled this revision from to [CUDA] Added device-side std::{malloc/free}.
tra updated this object.
tra added a reviewer: jlebar.
tra added a subscriber: cfe-commits.
jlebar accepted this revision.Jan 27 2016, 11:18 AM
jlebar edited edge metadata.
jlebar added inline comments.
lib/Headers/__clang_cuda_cmath.h
222 ↗(On Diff #46151)

Not really math stuff; maybe they should live in the main header?

lib/Headers/__clang_cuda_runtime_wrapper.h
170

Perhaps add a comment explaining where these are implemented?

This revision is now accepted and ready to land.Jan 27 2016, 11:18 AM
tra updated this revision to Diff 46729.Feb 2 2016, 5:25 PM
tra edited edge metadata.

Added few more device-side system calls and related wrapper functions.
Added nothrow attributes on malloc/free.

jlebar added inline comments.Feb 2 2016, 6:17 PM
lib/Headers/__clang_cuda_runtime_wrapper.h
215

It seems that only vprintf, free, malloc, and __assertfail are syscalls? If so please rejigger this comment so that it's clear what it is and isn't covering.

232

I'd prefer to keep the information from the previous comment: This declaration is there for type-safety, not because things will fail to compile if it is removed.

Otherwise someone may look at this, delete this definition, see that everything still works, and conclude that they can safely remove this line.

234

Please put "// extern "C"

236

Nit: Period

242

Please add "//namespace std"

tra updated this revision to Diff 46803.Feb 3 2016, 10:12 AM
tra retitled this revision from [CUDA] Added device-side std::{malloc/free} to [CUDA] Added device-side system call decls and related wrappers..
tra updated this object.
tra marked 3 inline comments as done.

Addressed Justin's comments.

lg with one question about printf.

lib/Headers/__clang_cuda_runtime_wrapper.h
237

I think we want an attribute on this so that we know it's printf-like, so you get appropriate format-string warnings. Unless the compiler is going to add said attribute automatically based on the just the function name.

tra added inline comments.Feb 3 2016, 11:13 AM
lib/Headers/__clang_cuda_runtime_wrapper.h
232

I don't quite see what makes vprintf() special compared to other decls here or, let's say, in /usr/include/*.h. I think 'declaration is there for type safety' applies to all of them and does not need to be spelled out for each individual decl.

237

I've verified that lang is already aware that it's printf and checks arguments against format string appropriately.

tra updated this revision to Diff 46818.Feb 3 2016, 12:52 PM

Updated comment.

lgtm. Thank you.

tra closed this revision.Feb 3 2016, 1:00 PM

Committed in r259690