I am trying to parallelize a for-loop that updates array and scalar counters. I am able to reduce the scalar counters, but I get this error when I add the array counter.
ERROR: LoadError: syntax: invalid syntax in "local" declaration around C:\Users\User\.julia\packages\FLoops\AN2BM\src\reduce.jl:449
This is the function I was using. It takes an input file and uses the data of each row to find the appropriate element of the array counter to increment.
function parallel_test(Input, N_rows) counter_evens = 0 counter_odds = zeros(Int16, (N_rows)) @floop for i = 1:N_rows a = round(Input[i,1]) # some processing based on input data if a%2 == 0 c_evens = 1 @reduce(counter_evens += c_evens) else c_odds= 1 ind = round(rand()*a) # find array element to increment @reduce(counter_odds[ind] += c_odds) end end return counter_evens, counter_odds end Input_file = rand(1:9, (10,5)) .* rand() evens, odds = parallel_test(Input_file , 10)
Am I using
@reduce incorrectly, or is this configuration not possible with FLoops.jl?