Skip to content

Commit c4f01e3

Browse files
authored
Merge pull request #68 from jtb20/hyperv-fixes
Workarounds for using gpurun under Hyper-V
2 parents 7ded5e1 + 6d638b0 commit c4f01e3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

utils/bin/gpurun

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
# mpirun -np 4 gpurun env | grep ROCR_VISIBLE_DEVICES
2929
#
3030

31+
# If set to 1, just invoke the rest of the command line without doing anything
32+
# else.
33+
GPURUN_BYPASS=${GPURUN_BYPASS:-0}
34+
35+
if [ "$GPURUN_BYPASS" = "1" ]; then
36+
exec "$@"
37+
fi
38+
3139
# PROGVERSION string is updated by cmake when component is installed
3240
PROGVERSION=X.Y-Z
3341
function version(){
@@ -256,12 +264,10 @@ while read _linepair ; do
256264
_this_uuid=$_fieldvalue
257265
elif [ "$_fieldtype" == "BDFID" ] ; then
258266
if [[ $_last_device_type_was_gpu == 1 ]] ; then
259-
_bdfidstr=`echo "obase=16; $_fieldvalue" | bc | tr '[:upper:]' '[:lower:]'`
260-
if [ ${#_bdfidstr} == 3 ] ; then
261-
_bdfidstr="0${_bdfidstr:0:1}:${_bdfidstr:1:2}"
262-
else
263-
_bdfidstr="${_bdfidstr:0:2}:${_bdfidstr:2:2}"
264-
fi
267+
# _domain="$(echo "$_fieldvalue / (2^32)" | bc)"
268+
_bus="$(echo "($_fieldvalue / (2^8)) % (2^8)" | bc)"
269+
_devfn="$(echo "($_fieldvalue % (2^8))" | bc)"
270+
_bdfidstr="$(printf "%.2x:%.2x" "$_bus" "$_devfn")"
265271
fi
266272
elif [ "$_fieldtype" == "Name" ] ; then
267273
# The device name field is last in rocminfo output, so we can create new _ri_ array entry
@@ -354,9 +360,13 @@ for _devid in `ls $_sysdevdir` ; do
354360
done
355361
# Search _ri_ arrays for matching uuids or matching bdfids.
356362
for _ri_i in ${!_ri_bdfids[@]} ; do
357-
if [ $_has_unique_id_file == 1 ] ; then
363+
if [ "$_has_unique_id_file" == "1" ] ; then
358364
_ss_value=$_this_uuid
359365
_ri_value=${_ri_uuid[$_ri_i]}
366+
elif [ "${_ri_bdfids[$_ri_i]}" == "00:00" ]; then
367+
# Under Hyper-V, we may see a zero BDFID. Fall back to UUID.
368+
_ss_value=$_devid
369+
_ri_value=$_devid
360370
else
361371
_ss_value=$_devid
362372
_ri_value="0000:${_ri_bdfids[$_ri_i]}.0"

0 commit comments

Comments
 (0)