@@ -350,59 +350,79 @@ end
350
350
end
351
351
352
352
@testset " Scheduler algorithms" begin
353
- # New function to hide from scheduler's function cost cache
354
- mynothing (args... ) = nothing
353
+ @testset " Signature Calculation" begin
354
+ @test Dagger. Sch. signature (+ , [nothing => 1 , nothing => 2 ]) isa Vector{DataType}
355
+ @test Dagger. Sch. signature (+ , [nothing => 1 , nothing => 2 ]) == [typeof (+ ), Int, Int]
356
+ if isdefined (Core, :kwcall )
357
+ @test Dagger. Sch. signature (+ , [nothing => 1 , :a => 2 ]) == [typeof (Core. kwcall), @NamedTuple {a:: Int64 }, typeof (+ ), Int]
358
+ else
359
+ kw_f = Core. kwfunc (+ )
360
+ @test Dagger. Sch. signature (+ , [nothing => 1 , :a => 2 ]) == [typeof (kw_f), @NamedTuple {a:: Int64 }, typeof (+ ), Int]
361
+ end
362
+ @test Dagger. Sch. signature (+ , []) == [typeof (+ )]
363
+ @test Dagger. Sch. signature (+ , [nothing => 1 ]) == [typeof (+ ), Int]
355
364
356
- # New non-singleton struct to hide from `approx_size`
357
- struct MyStruct
358
- x:: Int
365
+ c = Dagger. tochunk (1.0 )
366
+ @test Dagger. Sch. signature (* , [nothing => c, nothing => 3 ]) == [typeof (* ), Float64, Int]
367
+ t = Dagger. @spawn 1 + 2
368
+ @test Dagger. Sch. signature (/ , [nothing => t, nothing => c, nothing => 3 ]) == [typeof (/ ), Int, Float64, Int]
359
369
end
360
370
361
- state = Dagger. Sch. EAGER_STATE[]
362
- tproc1 = Dagger. ThreadProc (1 , 1 )
363
- tproc2 = Dagger. ThreadProc (first (workers ()), 1 )
364
- procs = [tproc1, tproc2]
365
-
366
- pres1 = state. worker_time_pressure[1 ][tproc1]
367
- pres2 = state. worker_time_pressure[first (workers ())][tproc2]
368
- tx_rate = state. transfer_rate[]
369
-
370
- for (args, tx_size) in [
371
- ([1 , 2 ], 0 ),
372
- ([Dagger. tochunk (1 ), 2 ], sizeof (Int)),
373
- ([1 , Dagger. tochunk (2 )], sizeof (Int)),
374
- ([Dagger. tochunk (1 ), Dagger. tochunk (2 )], 2 * sizeof (Int)),
375
- # TODO : Why does this work? Seems slow
376
- ([Dagger. tochunk (MyStruct (1 ))], sizeof (MyStruct)),
377
- ([Dagger. tochunk (MyStruct (1 )), Dagger. tochunk (1 )], sizeof (MyStruct)+ sizeof (Int)),
378
- ]
379
- for arg in args
380
- if arg isa Chunk
381
- aff = Dagger. affinity (arg)
382
- @test aff[1 ] == OSProc (1 )
383
- @test aff[2 ] == MemPool. approx_size (MemPool. poolget (arg. handle))
384
- end
371
+ @testset " Cost Estimation" begin
372
+ # New function to hide from scheduler's function cost cache
373
+ mynothing (args... ) = nothing
374
+
375
+ # New non-singleton struct to hide from `approx_size`
376
+ struct MyStruct
377
+ x:: Int
385
378
end
386
379
387
- cargs = map (arg-> MemPool. poolget (arg. handle), filter (arg-> isa (arg, Chunk), args))
388
- est_tx_size = Dagger. Sch. impute_sum (map (MemPool. approx_size, cargs))
389
- @test est_tx_size == tx_size
380
+ state = Dagger. Sch. EAGER_STATE[]
381
+ tproc1 = Dagger. ThreadProc (1 , 1 )
382
+ tproc2 = Dagger. ThreadProc (first (workers ()), 1 )
383
+ procs = [tproc1, tproc2]
384
+
385
+ pres1 = state. worker_time_pressure[1 ][tproc1]
386
+ pres2 = state. worker_time_pressure[first (workers ())][tproc2]
387
+ tx_rate = state. transfer_rate[]
388
+
389
+ for (args, tx_size) in [
390
+ ([1 , 2 ], 0 ),
391
+ ([Dagger. tochunk (1 ), 2 ], sizeof (Int)),
392
+ ([1 , Dagger. tochunk (2 )], sizeof (Int)),
393
+ ([Dagger. tochunk (1 ), Dagger. tochunk (2 )], 2 * sizeof (Int)),
394
+ # TODO : Why does this work? Seems slow
395
+ ([Dagger. tochunk (MyStruct (1 ))], sizeof (MyStruct)),
396
+ ([Dagger. tochunk (MyStruct (1 )), Dagger. tochunk (1 )], sizeof (MyStruct)+ sizeof (Int)),
397
+ ]
398
+ for arg in args
399
+ if arg isa Chunk
400
+ aff = Dagger. affinity (arg)
401
+ @test aff[1 ] == OSProc (1 )
402
+ @test aff[2 ] == MemPool. approx_size (MemPool. poolget (arg. handle))
403
+ end
404
+ end
390
405
391
- t = delayed (mynothing)( args... )
392
- inputs = Dagger. Sch. collect_task_inputs (state, t )
393
- sorted_procs, costs = Dagger . Sch . estimate_task_costs (state, procs, t, inputs)
406
+ cargs = map (arg -> MemPool . poolget (arg . handle), filter (arg -> isa (arg, Chunk), args) )
407
+ est_tx_size = Dagger. Sch. impute_sum ( map (MemPool . approx_size, cargs) )
408
+ @test est_tx_size == tx_size
394
409
395
- @test tproc1 in sorted_procs
396
- @test tproc2 in sorted_procs
397
- if length (cargs) > 0
398
- @test sorted_procs[1 ] == tproc1
399
- @test sorted_procs[2 ] == tproc2
400
- end
410
+ t = delayed (mynothing)(args... )
411
+ inputs = Dagger. Sch. collect_task_inputs (state, t)
412
+ sorted_procs, costs = Dagger. Sch. estimate_task_costs (state, procs, t, inputs)
401
413
402
- @test haskey (costs, tproc1)
403
- @test haskey (costs, tproc2)
404
- @test costs[tproc1] ≈ pres1 # All chunks are local
405
- @test costs[tproc2] ≈ (tx_size/ tx_rate) + pres2 # All chunks are remote
414
+ @test tproc1 in sorted_procs
415
+ @test tproc2 in sorted_procs
416
+ if length (cargs) > 0
417
+ @test sorted_procs[1 ] == tproc1
418
+ @test sorted_procs[2 ] == tproc2
419
+ end
420
+
421
+ @test haskey (costs, tproc1)
422
+ @test haskey (costs, tproc2)
423
+ @test costs[tproc1] ≈ pres1 # All chunks are local
424
+ @test costs[tproc2] ≈ (tx_size/ tx_rate) + pres2 # All chunks are remote
425
+ end
406
426
end
407
427
end
408
428
0 commit comments