Skip to content

Commit e4d6efd

Browse files
committed
Remove unreachable matrix generation functionality in C generator
1 parent a55dd4b commit e4d6efd

File tree

1 file changed

+8
-38
lines changed

1 file changed

+8
-38
lines changed

src/code_gen/gen_c_code.jl

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -592,36 +592,14 @@ function generate_random_entry(lang::LangC, ::Type{T}) where {T<:Complex}
592592
return assignment_string(lang, "A[i]", random_string(), random_string())
593593
end
594594

595-
function scalar_to_string(::LangC, z)
596-
return "$z"
597-
end
598-
function scalar_to_string(::LangC_OpenBLAS, z::T) where {T<:Complex}
599-
return "$(real(z)) + $(imag(z)) * I"
600-
end
601-
function scalar_to_string(::LangC_MKL, z::T) where {T<:Complex}
602-
return "{$(real(z)), $(imag(z))}"
603-
end
604-
function print_indented_matrix(lang::LangC, code, A; ind_lvl = 1)
605-
(m, n) = size(A)
606-
for j = 1:n
607-
column_string = ""
608-
for i = 1:m
609-
column_string *=
610-
scalar_to_string(lang, A[i, j]) * (i != m ? ", " : "")
611-
end
612-
column_string *= (j != n ? "," : "")
613-
push_code!(code, column_string, ind_lvl = ind_lvl)
614-
end
615-
end
616-
617595
function compilation_string(::LangC_OpenBLAS, fname)
618596
return "gcc -o main_compiled $fname -lblas -llapacke"
619597
end
620598
function compilation_string(::LangC_MKL, fname)
621599
return "gcc -o main_compiled $fname -lmkl_rt"
622600
end
623601

624-
function gen_main(lang::LangC, T, fname, funname, graph; A = 10::Union{Integer,Matrix})
602+
function gen_main(lang::LangC, T, fname, funname, graph)
625603
code = init_code(lang)
626604
if (lang.gen_main)
627605
(blas_type, blas_prefix) = get_blas_type(lang, T)
@@ -647,21 +625,13 @@ function gen_main(lang::LangC, T, fname, funname, graph; A = 10::Union{Integer,M
647625
push_code!(code, "size_t i;")
648626

649627
# Generate matrix.
650-
if isa(A, Matrix)
651-
n = LinearAlgebra.checksquare(A)
652-
push_code!(code, "size_t n = $n;")
653-
push_code!(code, "blas_type A[$(n * n)] = {")
654-
print_indented_matrix(lang, code, A, ind_lvl = 2)
655-
push_code!(code, "};")
656-
else # A is an integer
657-
n = A
658-
push_code!(code, "size_t n = $n;")
659-
push_code!(code, "srand(0);")
660-
push_code!(code, "blas_type *A = malloc(n * n * sizeof(*A));")
661-
push_code!(code, "for(i = 0; i < n * n; i++){")
662-
push_code!(code, generate_random_entry(lang, eltype(graph)), ind_lvl = 2)
663-
push_code!(code, "}")
664-
end
628+
n = 4
629+
push_code!(code, "size_t n = $n;")
630+
push_code!(code, "srand(0);")
631+
push_code!(code, "blas_type *A = malloc(n * n * sizeof(*A));")
632+
push_code!(code, "for(i = 0; i < n * n; i++){")
633+
push_code!(code, generate_random_entry(lang, eltype(graph)), ind_lvl = 2)
634+
push_code!(code, "}")
665635

666636
# Call polynomial evaluation function.
667637
push_code!(code, "blas_type *B = malloc(n * n * sizeof(*A));")

0 commit comments

Comments
 (0)