Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _wrapper_device_link artifact name conflict #135

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cuda/private/actions/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def compile(
srcs,
common,
pic = False,
rdc = False):
rdc = False,
_prefix = "_objs"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you missing the change in this function to actually make use of this prefix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Burried in another branch.

"""Perform CUDA compilation, return compiled object files.

Notes:
Expand All @@ -26,6 +27,7 @@ def compile(
common: A cuda common object. Can be obtained with `cuda_helper.create_common(ctx)`
pic: Whether the `srcs` are compiled for position independent code.
rdc: Whether the `srcs` are compiled for relocatable device code.
_prefix: DON'T USE IT! Prefix of the output dir. Exposed for device link to redirect the output.

Returns:
An compiled object `File`.
Expand Down Expand Up @@ -53,13 +55,13 @@ def compile(
filename = None
filename = cuda_helper.get_artifact_name(cuda_toolchain, artifact_category_name, basename)

# Objects are placed in _objs/<tgt_name>/<filename>.
# Objects are placed in <_prefix>/<tgt_name>/<filename>.
# For files with the same basename, say srcs = ["kernel.cu", "foo/kernel.cu", "bar/kernel.cu"], we get
# _objs/<tgt_name>/0/kernel.<ext>, _objs/<tgt_name>/1/kernel.<ext>, _objs/<tgt_name>/2/kernel.<ext>.
# <_prefix>/<tgt_name>/0/kernel.<ext>, <_prefix>/<tgt_name>/1/kernel.<ext>, <_prefix>/<tgt_name>/2/kernel.<ext>.
# Otherwise, the index is not presented.
if basename_counter[basename] > 1:
filename = "{}/{}".format(basename_index, filename)
obj_file = actions.declare_file("_objs/{}/{}".format(ctx.attr.name, filename))
obj_file = actions.declare_file("{}/{}/{}".format(_prefix, ctx.attr.name, filename))
ret.append(obj_file)

var = cuda_helper.create_compile_variables(
Expand Down
2 changes: 1 addition & 1 deletion cuda/private/actions/dlink.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,5 @@ def _wrapper_device_link(
# suppress cuda mode as c++ mode
host_compile_flags = common.host_compile_flags + ["-x", "c++"],
)
ret = compile(ctx, cuda_toolchain, cc_toolchain, srcs = [fatbin_c], common = compile_common, pic = pic, rdc = rdc)
ret = compile(ctx, cuda_toolchain, cc_toolchain, srcs = [fatbin_c], common = compile_common, pic = pic, rdc = rdc, _prefix = "_objs/_dlink")
return ret[0]
Loading