Search Unity

the c# job system lacking atomic increment style output list/array

Discussion in 'C# Job System' started by dizzy2003, Mar 10, 2018.

  1. dizzy2003

    dizzy2003

    Joined:
    Nov 25, 2013
    Posts:
    108
    Maybe I'm missing something but I cant see anyway to output variable length data from the job system.

    Like how ComputeBuffers can multithread append to a list (so long as it doesnt overflow the initial allocation).

    This is pretty essential for any useful work.

    For example creating a list of indicies for items to be destroyed from the input array data.

    Create a variable length output list of vector3's of positions to spawn partical systems.

    Essentially anything that needs to build an output list that doesnt match the source data length..
     
  2. Until they implement something like that:

    How about creating an array of same size of the original and write in only the elements you want to touch? You will need this either way in case you want to touch all the input elements.
    They probably will do the same when they implement such a thing.
     
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
  4. dizzy2003

    dizzy2003

    Joined:
    Nov 25, 2013
    Posts:
    108
    @LurkingNinjaDev thats no good at all, if I'm traversing a million items and outputting 20 items, I dont want to have to search a million items for the 20 flagged as having interesting data..

    Thanks superpig, it looks like filter jobs are coming, I tried the NativeList and nativeQueue provided by the zip of latest Native containers, but sadly neither provide parallel write support :(
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    IJobParallelForFilter curenntly doesn't support for parallel for writing support. Filter jobs run on a single job right now.
    The implementation is in full source and you can add support for parallel writing yourself but we will eventually add support for it.

    That said NativeQueue.Concurrent type can be used for parallel for writing to a queue. You can check out some of the test coverage code for it.