# ===----------------------------------------------------------------------=== #
# Copyright (c) 2026, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===----------------------------------------------------------------------=== #

from std.collections import List
from spmv_utils import CSCMatrix, generate_sparse_matrix, spmv_cpu, verify
from std.gpu import block_idx, thread_idx, block_dim
from std.gpu.host import DeviceContext
from std.atomic import Atomic


@fieldwise_init
struct Element(Comparable, ImplicitlyCopyable):
    var r: UInt32
    var c: UInt32
    var v: Float32

    def __lt__(self, other: Self) -> Bool:
        if self.c != other.c:
            return self.c < other.c
        return self.r < other.r

    def __eq__(self, other: Self) -> Bool:
        return self.c == other.c and self.r == other.r

    def __init__(out self, *, deinit take: Self):
        self.r = take.r
        self.c = take.c
        self.v = take.v

    def __init__(out self, *, copy: Self):
        self.r = copy.r
        self.c = copy.c
        self.v = copy.v


def spmv_csc_kernel(
    cscMatrix: CSCMatrix,
    x: UnsafePointer[Float32, MutAnyOrigin],
    y: UnsafePointer[Float32, MutAnyOrigin],
):
