Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
lpawela committed Apr 17, 2024
1 parent d186a94 commit 70d619a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions benchmarks/bf_bench.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SpinGlassNetworks
using LightGraphs
using Graphs
using SpinGlassExhaustive
using LinearAlgebra
using CUDA
Expand All @@ -13,6 +13,7 @@ function bench_cpu(instance::String, max_states::Int=100)
ig = ising_graph(instance)
cl = split_into_clusters(ig, super_square_lattice((m, n, t)))
@time sp = brute_force(cl[1, 1], num_states=max_states)
Spectrum
sp
end

Expand All @@ -36,7 +37,9 @@ sp_gpu = bench_gpu("$(@__DIR__)/pegasus_droplets/2_2_3_00.txt")
sp_gpu = bench_gpu("$(@__DIR__)/pegasus_droplets/2_2_3_00.txt")

@assert sp_gpu.energies sp_cpu.energies
@assert sp_gpu.states == sp_cpu.states
@show sp_gpu.states
@show sp_cpu.states[1]
@assert sp_gpu.states == sp_cpu.states[1]

"""
$(SIGNATURES)
Expand Down
2 changes: 1 addition & 1 deletion src/ising.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export energy_qubo, energy, kernel, kernel_qubo, kernel_part, exhaustive_search,

struct Spectrum
energies::AbstractVector
states::Vector{Int}
states::Union{VecOrMat{Int}, VecOrMat{Int32}}
end

"""
Expand Down
2 changes: 1 addition & 1 deletion src/naive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ function SpinGlassNetworks.brute_force(
perm = sortperm(energies)[1:num_states]
energies_cpu = Array(view(energies, perm))
σ_cpu = Array(view(σ, :, perm))
Spectrum(energies_cpu, [σ_cpu[:, i] for i 1:size(σ_cpu, 2)])
Spectrum(energies_cpu, σ_cpu)
end

0 comments on commit 70d619a

Please sign in to comment.