diff --git a/hipamd/bin/hipcc b/hipamd/bin/hipcc index b40b4ee855..624777ab25 100755 --- a/hipamd/bin/hipcc +++ b/hipamd/bin/hipcc @@ -345,77 +345,73 @@ foreach $arg (@ARGV) } if($HIP_PLATFORM eq "hcc"){ - # No AMDGPU target specified at commandline - if($default_amdgpu_target eq 1) + # No AMDGPU target specified at commandline. So look for HCC_AMDGPU_TARGET + if($default_amdgpu_target eq 1 and defined $ENV{HCC_AMDGPU_TARGET}) { - # Look for HCC_AMDGPU_TARGET - if(defined $ENV{HCC_AMDGPU_TARGET}) + foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) { - foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) + if($target eq 'gfx701') { - if($target eq 'gfx701') - { - $target_gfx701 = 1; - $default_amdgpu_target = 0; - } - if($target eq 'gfx801') - { - $target_gfx801 = 1; - $default_amdgpu_target = 0; - } - if($target eq 'gfx802') - { - $target_gfx802 = 1; - $default_amdgpu_target = 0; - } - if($target eq 'gfx803') - { - $target_gfx803 = 1; - $default_amdgpu_target = 0; - } - if($target eq 'gfx900') - { - $target_gfx900 = 1; - $default_amdgpu_target = 0; - } + $target_gfx701 = 1; + $default_amdgpu_target = 0; } - } - # Else try using rocm_agent_enumerator - else - { - $ROCM_AGENT_ENUM = "${ROCM_PATH}/bin/rocm_agent_enumerator"; - - my $myAgents = `${ROCM_AGENT_ENUM} -t GPU`; - my @agentsLine = split('\n', $myAgents); - - foreach my $val (@agentsLine) { - if($val eq "gfx701") { - $target_gfx701 = 1; - $default_amdgpu_target = 0; - } - if($val eq "gfx801") { - $target_gfx801 = 1; - $default_amdgpu_target = 0; - } - if($val eq "gfx802") { - $target_gfx802 = 1; - $default_amdgpu_target = 0; - } - if($val eq "gfx803") { - $target_gfx803 = 1; - $default_amdgpu_target = 0; - } - if($val eq "gfx900") { - $target_gfx900 = 1; - $default_amdgpu_target = 0; - } + if($target eq 'gfx801') + { + $target_gfx801 = 1; + $default_amdgpu_target = 0; + } + if($target eq 'gfx802') + { + $target_gfx802 = 1; + $default_amdgpu_target = 0; + } + if($target eq 'gfx803') + { + $target_gfx803 = 1; + $default_amdgpu_target = 0; + } + if($target eq 'gfx900') + { + $target_gfx900 = 1; + $default_amdgpu_target = 0; } } } - # All options including enumerator failed! Fallback to gfx803 for now - if ($default_amdgpu_target eq 1) + # Else try using rocm_agent_enumerator + if($default_amdgpu_target eq 1) { - $target_gfx803 = 1; + $ROCM_AGENT_ENUM = "${ROCM_PATH}/bin/rocm_agent_enumerator"; + + my $myAgents = `${ROCM_AGENT_ENUM} -t GPU`; + my @agentsLine = split('\n', $myAgents); + + foreach my $val (@agentsLine) { + if($val eq "gfx701") { + $target_gfx701 = 1; + $default_amdgpu_target = 0; + } + if($val eq "gfx801") { + $target_gfx801 = 1; + $default_amdgpu_target = 0; + } + if($val eq "gfx802") { + $target_gfx802 = 1; + $default_amdgpu_target = 0; + } + if($val eq "gfx803") { + $target_gfx803 = 1; + $default_amdgpu_target = 0; + } + if($val eq "gfx900") { + $target_gfx900 = 1; + $default_amdgpu_target = 0; + } + } + } + # rocm_agent_enumerator failed! Throw an error and die if linking is required + if ($default_amdgpu_target eq 1 and $compileOnly eq 0) + { + print "No valid AMD GPU target was either specified or found. Please specify a valid target using --amdgpu-target=" and die(); } $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n";