Skip to content
Snippets Groups Projects
Commit a62975b5 authored by Nicola Vigano's avatar Nicola Vigano Committed by Nicola Vigano
Browse files

dct_launch: fixed matlab_script invocation and added valgrind debugging support

parent 7097d4ff
No related branches found
No related tags found
No related merge requests found
......@@ -86,14 +86,21 @@ class DCTLauncher(object):
if (len(self.args) is not 0) and self.args[0] in ("-h", "--help"):
print(" Usage:")
print(" # python %s matlab_script [matlab_commands]" % os.path.basename(__file__))
print(" Where [matlab_commands] could be a script name or malab commands")
print(" # python %s matlab_script [commands]" % os.path.basename(__file__))
print(" Options:")
print(" -h | --help : to show this help")
print(" --profile : to specify the type of profiling. Options: 'cuda'")
print(" --debug : to specify the type of profiling. Options: 'valgrind'")
print(" --script : to specify the script/commands to be launched")
else:
decoded_args = dct.dct_matlab_invocation.DCTMatlabInvocation.filter_parameters(self.args)
invoker = dct.dct_matlab_invocation.DCTMatlabInvocation(dct_dir = self.dct_dir, \
extra_cmds = self.args, \
extra_cmds = decoded_args["script"], \
skip_functions_check = True)
invoker.invoke()
invoker.invoke(profiler=decoded_args['profile'], \
debugger=decoded_args['debug'])
def _launchUpdate(self):
util = dct.dct_utils_git.DCTGit(self.dct_dir)
......
......@@ -6,6 +6,7 @@ Created on Feb 7, 2013
import os
import subprocess
import re
from . import dct_io_xml
from . import dct_utils_platform
......@@ -29,7 +30,30 @@ class DCTMatlabInvocation(object):
self.utils = dct_utils_platform.UtilsFactory.getMachineDep()
def invoke(self):
@staticmethod
def filter_parameters(args):
launcher_accepted_args = ("--profile", "--debug", "--script")
decoded_args = { 'profile' : None, 'debug' : None, 'script' : None }
skip_next = False
for ind_arg in range(len(args)):
if skip_next is True:
skip_next = False
continue
for modifier in launcher_accepted_args:
if args[ind_arg] == modifier:
if len(args) <= (ind_arg + 1):
raise ValueError("Not enough arguments for modifier: %s" % modifier)
if decoded_args[modifier[2:]] is not None:
dct_io_xml.DCTOutput.printWarning( \
"Overwriting previous argument '%s' for modifier '%s', with argument '%s'" \
% decoded_args[modifier[2:]], modifier, args[ind_arg+1])
decoded_args[modifier[2:]] = args[ind_arg+1]
skip_next = True
if decoded_args["profile"] is not None and decoded_args["debug"] is not None:
raise ValueError("Profiling and debugging cannot be used at the same time!")
return decoded_args
def invoke(self, profiler = None, debugger = None):
self.conf = dct_io_xml.DCTConf(self.confPath)
# Adding runtime libraries
......@@ -54,7 +78,12 @@ class DCTMatlabInvocation(object):
env_var = os.environ["LD_PRELOAD"]
os.environ["LD_PRELOAD"] = ":".join([lib, env_var])
cmd = [os.path.join(self.conf.getMatlabPath(), "bin", "matlab")]
cmd = []
if profiler == "cuda":
cmd = cmd + ["/usr/local/cuda/bin/nvprof", "-f", "-o", "profile_cuda_matlab_script"] #, "--analysis-metrics"
if debugger == "valgrind":
cmd = cmd + ["valgrind", "--log-file=memcheck_matlab_script"] #, "--leak-check=yes"
cmd = cmd + [os.path.join(self.conf.getMatlabPath(), "bin", "matlab")]
cmd = cmd + self.conf.getMatlabOptions()
cmd = cmd + self.args
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment