public ParallelJobsContext(IDependableMemoryResource output)
 {
     outputResource   = output;
     combinedJobFence = new JobHandle();
     Assert.AreEqual(0, s_ReadDependencyTracker.Count,
                     "s_ReadDependencyTracker should be empty meaning ParrallelJobs was not disposed properly.");
 }
 private static void SetXOFences(this JobHandle jobFence,
                                 IDependableMemoryResource pinX,
                                 IDependableMemoryResource pinO)
 {
     pinX.reuse = jobFence;
     pinO.fence = jobFence;
 }
 private static JobHandle GetFenceBeforeJobStartXBO(
     IDependableMemoryResource pinX,
     IDependableMemoryResource pinB,
     IDependableMemoryResource pinO)
 {
     return(BurstCPUOps.Dependencies(pinX.fence, pinB.fence, pinO.reuse));
 }
 private void TrackJobReadDependencies(IDependableMemoryResource T, JobHandle jobFence)
 {
     //Once all jobs reading from T will be done, further jobs will be able to write to T.
     //We combine job fences from all jobs reading from T here and assign to T.reuse in Dispose().
     if (T != null)
     {
         if (s_ReadDependencyTracker.ContainsKey(T))
         {
             s_ReadDependencyTracker[T] = JobHandle.CombineDependencies(s_ReadDependencyTracker[T], jobFence);
         }
         else
         {
             s_ReadDependencyTracker[T] = jobFence;
         }
     }
 }
示例#5
0
        internal static unsafe JobHandle ScheduleO <T>(this T jobData,
                                                       IDependableMemoryResource O,
                                                       FencingHelperMode fencingMode = FencingHelperMode.UpdateResourcesFencesOnScheduling)
            where T : struct, IJob, BurstCPUOps.IJobResourceDeclarationO
        {
            var fenceBeforeJobStart = O.reuse;

            JobHandle jobFence;

            {
                jobFence = ScheduleOInternal(jobData, fenceBeforeJobStart, O.rawPtr);
            }

            if (fencingMode == FencingHelperMode.UpdateResourcesFencesOnScheduling)
            {
                O.fence = jobFence;
            }

            return(jobFence);
        }
示例#6
0
        internal static unsafe JobHandle ScheduleXO <T>(this T jobData,
                                                        IDependableMemoryResource X,
                                                        IDependableMemoryResource O,
                                                        FencingHelperMode fencingMode = FencingHelperMode.UpdateResourcesFencesOnScheduling)
            where T : struct, IJob, BurstCPUOps.IJobResourceDeclarationXO
        {
            var fenceBeforeJobStart = GetFenceBeforeJobStartXO(X, O);

            JobHandle jobFence;

            {
                jobFence = ScheduleXOInternal(jobData, fenceBeforeJobStart, X.rawPtr, O.rawPtr);
            }

            if (fencingMode == FencingHelperMode.UpdateResourcesFencesOnScheduling)
            {
                jobFence.SetXOFences(X, O);
            }

            return(jobFence);
        }
示例#7
0
        internal static unsafe JobHandle ScheduleXBO <T>(this T jobData,
                                                         IDependableMemoryResource X,
                                                         IDependableMemoryResource B,
                                                         IDependableMemoryResource O,
                                                         int arrayLength, int innerloopBatchCount,
                                                         FencingHelperMode fencingMode = FencingHelperMode.UpdateResourcesFencesOnScheduling)
            where T : struct, IJobParallelFor, BurstCPUOps.IJobResourceDeclarationXBO
        {
            var fenceBeforeJobStart = GetFenceBeforeJobStartXBO(X, B, O);

            JobHandle jobFence;

            {
                jobFence = ScheduleXBOInternal(jobData, fenceBeforeJobStart, X.rawPtr, B.rawPtr, O.rawPtr, arrayLength, innerloopBatchCount);
            }

            if (fencingMode == FencingHelperMode.UpdateResourcesFencesOnScheduling)
            {
                jobFence.SetXBOFences(X, B, O);
            }

            return(jobFence);
        }