gaia_assembler/backends/gcn/
mod.rs1use crate::{
2 backends::{Backend, GeneratedFiles},
3 config::GaiaConfig,
4 instruction::{DomainInstruction, GaiaInstruction},
5 program::{GaiaModule, GaiaTerminator},
6};
7use gaia_types::{
8 helpers::{AbiCompatible, ApiCompatible, Architecture, ArtifactType, CompilationTarget},
9 neural::NeuralNode,
10 Result,
11};
12use gcn_assembler::{
13 instructions::{GcnInstruction, GcnReg},
14 program::{GcnKernel, GcnProgram},
15 GcnWriter,
16};
17use std::collections::HashMap;
18
19pub struct GcnBackend {
20 writer: GcnWriter,
21}
22
23impl GcnBackend {
24 pub fn new() -> Self {
25 Self { writer: GcnWriter::new() }
26 }
27}
28
29impl Backend for GcnBackend {
30 fn name(&self) -> &'static str {
31 "AMD GCN"
32 }
33
34 fn primary_target(&self) -> CompilationTarget {
35 CompilationTarget { build: Architecture::GCN, host: AbiCompatible::GCN, target: ApiCompatible::Unknown }
36 }
37
38 fn artifact_type(&self) -> ArtifactType {
39 ArtifactType::Executable
40 }
41
42 fn match_score(&self, target: &CompilationTarget) -> f32 {
43 if target.build == Architecture::GCN {
44 return 100.0;
45 }
46 0.0
47 }
48
49 fn generate(&self, program: &GaiaModule, config: &GaiaConfig) -> Result<GeneratedFiles> {
50 let mut files = HashMap::new();
51
52 let gcn_program = convert_gaia_to_gcn(program)?;
54
55 let binary = self.writer.write(&gcn_program)?;
57
58 files.insert("kernel.bin".to_string(), binary);
59
60 Ok(GeneratedFiles { artifact_type: ArtifactType::Executable, files, custom: None, diagnostics: vec![] })
61 }
62}
63
64fn convert_gaia_to_gcn(program: &GaiaModule) -> Result<GcnProgram> {
65 Ok(GcnProgram { name: program.name.clone(), kernels: vec![] })
67}