JuliaORNL / JACC.jl

CPU/GPU parallel performance portable layer in Julia via functions as arguments
MIT License
21 stars 13 forks source link

Allow to construct array in device functions #115

Open JValGLZ opened 1 month ago

JValGLZ commented 1 month ago

Part of my code uses a function to populate an array that holds 5 floats. The array is loaded with information that changes per iteration. The max value in that array is found then stored in another array. Initially, I wanted to create the array within the device meaning a new array would hold the calculated values. When I tried to do this, I got the following two errors:

Reason: unsupported call through a literal pointer (call to ijl_alloc_array_1d) Reason: unsupported dynamic function invocation

Instead I preallocated a JACC array that would be holding the five values and placed it as an argument in my parallel_for function. I set up a for loop to set all values to zero before any calculation was performed so that it may be cleared. The issue was that once I checked the data in that array, it was always from the first iteration. The array had kept the data from the previous calculation even though it was being cleared before the calculation was performed.

I believe by using the same preallocated array, there is some issue with clearing the data and updating.

Perhaps allowing the construction of an array within the device function would clear this issue.