Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapreduce failure with CartesianIndex values #259

Open
maleadt opened this issue Jan 18, 2023 · 0 comments
Open

mapreduce failure with CartesianIndex values #259

maleadt opened this issue Jan 18, 2023 · 0 comments
Labels
bug Something isn't working kernels Things about kernels and how they are compiled.

Comments

@maleadt
Copy link
Member

maleadt commented Jan 18, 2023

The following findfirst-like kernel fails when using CartesianIndices:

using oneAPI

function doit(xs)
    # works
    indices, dummy_index = eachindex(xs), 1

    # fails
    #indices, dummy_index = CartesianIndices(xs), CartesianIndex{ndims(xs)}()

    # given two pairs of (istrue, index), return the one with the smallest index
    function findfirst_reduction(t1, t2)
        (x, i), (y, j) = t1, t2
        if i > j
            t1, t2 = t2, t1
            (x, i), (y, j) = t1, t2
        end
        x && return t1
        y && return t2
        return (false, dummy_index)
    end

    res = mapreduce(tuple, findfirst_reduction, xs, indices;
                    init = (false, dummy_index))
    return res[1] ? res[2] : nothing
end

function main()
    x = [false false; true false]
    @show i = doit(oneArray(x))
    @assert i !== nothing
    @assert x[i]
end
@maleadt maleadt added the bug Something isn't working label Jan 18, 2023
@maleadt maleadt added the kernels Things about kernels and how they are compiled. label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kernels Things about kernels and how they are compiled.
Projects
None yet
Development

No branches or pull requests

1 participant