Skip to content

Commit

Permalink
ocl: improved tuning script
Browse files Browse the repository at this point in the history
* Ensure printing the case before running it.
* Common error message.
  • Loading branch information
hfp committed Jul 10, 2024
1 parent 0cffc63 commit 40bf500
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/acc/opencl/smm/opencl_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sed -n "s/FAILED\[..*\] \(..*\): \(..*\)/\1 \2/p" "$1" | while read -r LINE; do
EXPORT="${EXPORT} OPENCL_LIBSMM_SMM_${KEYVAL}"
done
if [ "${EXPORT}" ]; then
OUTPUT=$(eval "${EXPORT} ${EXE} ${MNK} 2>&1" | sed "s/^/ /")
echo -e "${MNK}: ${KEYVALS}\n${OUTPUT}"
echo "${MNK}: ${KEYVALS}"
eval "${EXPORT} ${EXE} ${MNK} 2>&1" | sed "s/^/ /"
fi
done
13 changes: 6 additions & 7 deletions src/acc/opencl/smm/tune_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,13 @@ def run(self, desired_result, input, limit):
cfgenv + ["CHECK={}".format(self.args.check)], verbose=self.args.verbose
)
self.run_result = self.call_program(runcmd)
returncode = self.run_result["returncode"]
if 0 == returncode:
result = self.run_result["returncode"]
if 0 == result:
performance = re.search(
"device:\\s+([0-9]+[^ ]*) ms\\s+([0-9]+[^ ]*)",
str(self.run_result["stdout"]),
)
else:
if not returncode:
returncode = "?"
performance = None
if performance and performance.group(1) and performance.group(2):
mseconds = float(performance.group(1))
Expand All @@ -325,7 +323,7 @@ def run(self, desired_result, input, limit):
else runcmd
)
mnk = "x".join(map(str, self.mnk))
print("FAILED[{}] {}: {}".format(returncode, mnk, failed), flush=True)
print("FAILED[{}] {}: {}".format(result, mnk, failed), flush=True)
return Result(time=float("inf"), accuracy=0.0, size=100.0)

def update_jsons(self, filenames):
Expand Down Expand Up @@ -504,8 +502,8 @@ def save_final_config(self, configuration, final=True):
return # nothing to save
config = configuration.data if configuration else None
cfgenv = self.environment(config) if config else None
result = self.run_result["returncode"] if config and self.run_result else 1
envchk = os.getenv("CHECK") # conside CHECKing result unless CHECK=0
result = self.run_result["returncode"] if config and self.run_result else 1
if 0 == result and 0 == self.args.check and (envchk is None or "0" != envchk):
self.run_result = self.call_program(self.launch(cfgenv + ["CHECK=1"]))
result = self.run_result["returncode"] if self.run_result else 1
Expand Down Expand Up @@ -555,7 +553,8 @@ def save_final_config(self, configuration, final=True):
# check return code (consider not saving parameters)
if 0 != result and not final: # incorrect result
failed = " ".join(map(str, cfgenv)).replace("OPENCL_LIBSMM_SMM_", "")
print("FAILED: {}".format(failed))
mnk = "x".join(map(str, self.mnk))
print("FAILED[{}] {}: {}".format(result, mnk, failed), flush=True)
return
if final and os.path.exists(filedot):
filepattern = "{}-*.json".format(default_basename)
Expand Down

0 comments on commit 40bf500

Please sign in to comment.