/* ═══════════════════════════════════════════════════════════════ AMDMigrationPanel — CUDA → ROCm Migration Advisor Shows compatibility score + per-finding migration guidance ═══════════════════════════════════════════════════════════════ */ import { useState } from 'react'; import './AMDMigrationPanel.css'; function ScoreCircle({ score }) { const radius = 58; const circumference = 2 * Math.PI * radius; const offset = circumference - (score / 100) * circumference; let colorClass = 'score-red'; let strokeClass = 'stroke-red'; if (score >= 90) { colorClass = 'score-green'; strokeClass = 'stroke-green'; } else if (score >= 70) { colorClass = 'score-yellow'; strokeClass = 'stroke-yellow'; } else if (score >= 50) { colorClass = 'score-orange'; strokeClass = 'stroke-orange'; } return (
{score} %
); } function MigrationFinding({ finding }) { const [expanded, setExpanded] = useState(false); const sevClass = `sev-${finding.severity}`; return (
setExpanded(!expanded)}> {finding.severity} {finding.id} {finding.title}
{expanded && (
{finding.file && (
📄 {finding.file}{finding.line ? `:${finding.line}` : ''}
)}

{finding.description}

🔧 ROCm Fix

{finding.rocm_fix}

)}
); } export default function AMDMigrationPanel({ migrationData }) { if (!migrationData) return null; const { compatibility_score = 100, compatibility_label = 'Fully ROCm Ready', findings = [], total_cuda_patterns_found = 0, summary = '', } = migrationData; let labelColor = 'score-red'; if (compatibility_score >= 90) labelColor = 'score-green'; else if (compatibility_score >= 70) labelColor = 'score-yellow'; else if (compatibility_score >= 50) labelColor = 'score-orange'; const handleExport = () => { let md = `# AMD ROCm Migration Guide — CodeSentry\n\n`; md += `## Compatibility Score: ${compatibility_score}% — ${compatibility_label}\n\n`; md += `## Found ${total_cuda_patterns_found} CUDA-Specific Pattern(s)\n\n`; if (summary) { md += `> ${summary}\n\n`; } md += `---\n\n`; findings.forEach((f) => { md += `### ${f.id}: ${f.title}\n\n`; md += `**Severity:** ${f.severity.toUpperCase()}\n\n`; if (f.file) { md += `**File:** \`${f.file}${f.line ? ':' + f.line : ''}\`\n\n`; } md += `**Issue:** ${f.description}\n\n`; md += `**ROCm Fix:** ${f.rocm_fix}\n\n`; if (f.code_snippet) { md += `**Code:**\n\`\`\`python\n${f.code_snippet}\n\`\`\`\n\n`; } md += `---\n\n`; }); md += `\n*Generated by CodeSentry AMD Migration Advisor*\n`; const blob = new Blob([md], { type: 'text/markdown' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'AMD_MIGRATION_GUIDE.md'; a.click(); URL.revokeObjectURL(url); }; return (
{/* Header */}
🔴

AMD ROCm Migration Advisor

{/* Score */}
{compatibility_label}
{/* Findings */} {findings.length > 0 ? (
{findings.map((f, idx) => ( ))}
) : (
✅ No CUDA-specific patterns detected
This codebase is fully AMD ROCm compatible
)} {/* Footer */}
{total_cuda_patterns_found > 0 ? `Apply all AMD fixes → Generate ROCm-optimized patch` : `Codebase verified for AMD MI300X deployment`}
); }