<#YC SCHOOL OF DIVINE PROGRAMMING
Easiest way to understand how to do Parallel Processing.
ppp ssh ll ll
p pooow weeerrrs h eeell ll
pp o owwwee r ss hhhee ll ll
pp ooow weeer ssh heeel llll rules.
p o w e r s h e l l
Please review over the components that need modfication as this can be used for any arraylist etc.
#>
#region set variables
$date_name = date -Format "yyyyMMddHHmmssfff"
$job_directory = "C:\_young\automation\job\$date_name"
$job_log = "C:\_young\automation\job\$date_name\job.log"
#endregion !!! modify the directory of "C:\_young\automation\job\" to your liking.
#endregion set variables
#region make the job directory and set write access for all workers
mkdir $job_directory
$acl = Get-Acl -Path $job_directory
$acl_rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
"Everyone",
"FullControl",
"ContainerInherit,ObjectInherit",
"None",
"Allow"
)
$acl.AddAccessRule($acl_rule)
Set-Acl -Path $job_directory -AclObject $acl
#!!! the above may or may not be required based on system permissions.
#endregion make the job directory
#region create the header for the log file
"date,worker,items_start,items_end,job_outfile" >> "$job_log"
#endregion
#region color grab
$number = 10
$try_max = 10
$try = 0
#strings vs integers
$store = "$([string]$number*)"
*$try_max
while ($try -le $try_max) {
$try++
$total += $number*$number
}
}
#region split array into items per worker
$job_array = @(0..16777217)
$job_items_max = $job_array.count
$total_workers = 4096
$job_items_per_thread = [math]::ceiling($job_items_max/$total_workers)
if ($job_items_max -le $job_items_per_thread*$total_workers) {write-host "Good"}else{write-host "Not Good"}
#!!! Please use your own array as needed. The example here is using numbers.
#!!! The ceiling value is used so we always cover for remainders. If we use round, the last job will be limited in count.
#endregion split array into items per worker
#region create job_array_range report for parallel processing
$report = @()
$item_range_index_value = 0
$worker = 0
while ($worker -le $total_workers) {
$worker++
$object = [pscustomobject] @{
worker = $worker
job_log = $job_log
job_outfile = "$job_directory\$($worker)"
items_start = $item_range_index_value
items_end = $item_range_index_value+$job_items_per_thread
job_status = ""
}
$item_range_index_value = ($object.items_end+1)
$report += $object
}
#endregion create job_array_range report for parallel processing
#region the script the worker processes
$job_script = {
$splat = $using:i
$array = $using:job_items
$date_name = date -Format "yyyyMMddHHmmssfff"
"$($date_name),$($splat.worker),$($splat.items_start),$($splat.items_end),$($splat.items_end),$($splat.job_outfile)" >> $splat.job_log
"tr>" >> $splat.job_outfile
foreach ($i in $array) {
("td style=""background-color:#$('{0:X6}' -f $i) ; height:25px; width:25px; border:solid 1px"">td>") >> $splat.job_outfile
}
"/tr>" >> $splat.job_outfile
"/td>" >> $splat.job_outfile
}
#!!! The above is the process against the array. You can have a seperate file or have that here listed.
#!!! I never do job-receive, I only output the file that I need too and confirm the job is completed.
#!!! If the job fails, I can always run the job seperately as it is in the report.
#!!! Failing memory retrival means complete restart.
#endregion the script the worker processes
<# Sample of report
worker : 514
job_log : C:\_young\automation\job\20250926021158806\job.log
job_outfile : C:\_young\automation\job\20250926021158806\514
items_start : 0
items_end : 65537
#>
#endregion create job_items and start the worker
foreach ($i in $report) {
$job_items = $job_array[$i.items_start..$i.items_end]
Start-Job -ScriptBlock $job_script
}
#!!! We use job_items for the reasons of memory efficiency.
#endregion create job_items and start the worker
$string = ""
$try_max = 4
for ($i=1;$i -le $try_max ;$i++) {
if ($try_max -eq $i) {
$string += [string]$number
$string += "="
} else {
$string += [string]$number
$string += "*"
}
}
<#
16777216
foreach ($i in 1..64) {
262,144*$i
}
4096*(1..64)
64x64 resolution
FOV
I have 16777216 colors
256x256x256 can be measure as x y z. layer z can be cool.
front side wall x=-128..128 y=-128..128 z=-128 black
back side wall x=-128..128 y=-128..128 z=-128 white
if you are at coord z is the major for front and back. we are looking at x and y 2D. -z at -1280 for front view
to go to the front -1280..1280 and then spin left how? you are x y z. the resolution of what you saw is only 256 flat screen. right? if you move in,
-1280-1 = the screen of 256x256 flat 2D whatever color it is.
left side wall x=-128 y=-128..128 z=-128..128
right side wall x= 128 y=-128..128 z=-128..128
satellite view x=-128..128 y= 128 z=-128..128
underground view x=-128..128 y=-128 z=-128..128
#ascii art
d xx xx
c xx xxxx xxxx xx
b xx xxxx xxxx xx
a xx xx
@12341234512341234
#>