mirror of
https://github.com/andreinechaev/nvcc4jupyter.git
synced 2026-06-16 12:10:49 +05:30
Add option to give nvcc extra arguments
This commit is contained in:
@@ -19,6 +19,7 @@ def get_parser_cuda() -> argparse.ArgumentParser:
|
|||||||
parser.add_argument("-t", "--timeit", action="store_true")
|
parser.add_argument("-t", "--timeit", action="store_true")
|
||||||
parser.add_argument("-p", "--profile", action="store_true")
|
parser.add_argument("-p", "--profile", action="store_true")
|
||||||
parser.add_argument("-a", "--profiler-args", type=str, default="")
|
parser.add_argument("-a", "--profiler-args", type=str, default="")
|
||||||
|
parser.add_argument("-c", "--compiler-args", type=str, default="")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+14
-13
@@ -87,7 +87,10 @@ class NVCCPlugin(Magics):
|
|||||||
shutil.rmtree(group_dirpath)
|
shutil.rmtree(group_dirpath)
|
||||||
|
|
||||||
def _compile(
|
def _compile(
|
||||||
self, group_name: str, executable_fname: str = DEFAULT_EXEC_FNAME
|
self,
|
||||||
|
group_name: str,
|
||||||
|
executable_fname: str = DEFAULT_EXEC_FNAME,
|
||||||
|
compiler_args: str = "",
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Compiles all source files in a given group together with all source
|
Compiles all source files in a given group together with all source
|
||||||
@@ -97,6 +100,7 @@ class NVCCPlugin(Magics):
|
|||||||
group_name: The name of the source file group to be compiled.
|
group_name: The name of the source file group to be compiled.
|
||||||
executable_fname: The output executable file name. Defaults to
|
executable_fname: The output executable file name. Defaults to
|
||||||
"cuda_exec.out".
|
"cuda_exec.out".
|
||||||
|
compiler_args: The optional "nvcc" compiler arguments.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RuntimeError: If the group does not exist or if does not have any
|
RuntimeError: If the group does not exist or if does not have any
|
||||||
@@ -121,18 +125,12 @@ class NVCCPlugin(Magics):
|
|||||||
|
|
||||||
executable_fpath = os.path.join(group_dirpath, executable_fname)
|
executable_fpath = os.path.join(group_dirpath, executable_fname)
|
||||||
|
|
||||||
args = [
|
args = ["nvcc"]
|
||||||
"nvcc",
|
args.extend(compiler_args.split())
|
||||||
"-I" + shared_dirpath + "," + group_dirpath,
|
args.append("-I" + shared_dirpath + "," + group_dirpath)
|
||||||
]
|
|
||||||
args.extend(source_files)
|
args.extend(source_files)
|
||||||
args.extend(
|
args.extend(["-o", executable_fpath, "-Wno-deprecated-gpu-targets"])
|
||||||
[
|
|
||||||
"-o",
|
|
||||||
executable_fpath,
|
|
||||||
"-Wno-deprecated-gpu-targets",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
return executable_fpath
|
return executable_fpath
|
||||||
@@ -188,7 +186,10 @@ class NVCCPlugin(Magics):
|
|||||||
self, group_name: str, args: argparse.Namespace
|
self, group_name: str, args: argparse.Namespace
|
||||||
) -> str:
|
) -> str:
|
||||||
try:
|
try:
|
||||||
exec_fpath = self._compile(group_name)
|
exec_fpath = self._compile(
|
||||||
|
group_name=group_name,
|
||||||
|
compiler_args=args.compiler_args,
|
||||||
|
)
|
||||||
output = self._run(
|
output = self._run(
|
||||||
exec_fpath=exec_fpath,
|
exec_fpath=exec_fpath,
|
||||||
timeit=args.timeit,
|
timeit=args.timeit,
|
||||||
|
|||||||
Reference in New Issue
Block a user