Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT fixes #32

Draft
wants to merge 39 commits into
base: conc-stacklets
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b4ced0
turn off debug
jeffmurphy Dec 14, 2021
b0d1f43
add instrumentation functions
jeffmurphy Dec 19, 2021
8ea2375
working on concurrency
jeffmurphy Dec 25, 2021
73c924c
concurrency
jeffmurphy Dec 30, 2021
615b5a5
concurrency fix for mult threads
jeffmurphy Jan 3, 2022
e8bdcbe
concurrency cleanup. see note.
jeffmurphy Jan 3, 2022
d8034a5
some notes on rtlinux deadline scheduler
jeffmurphy Jan 3, 2022
44fb9e3
expose rtlinux deadline scheduler via ffi
jeffmurphy Jan 4, 2022
6fce65f
rtems additions
jeffmurphy Feb 6, 2022
09c3176
add some doc to gc-check
jeffmurphy Feb 6, 2022
f4154af
add used field to chunk
jeffmurphy Feb 6, 2022
80f4ffd
pass object size into um_object_alloc
jeffmurphy Feb 6, 2022
a541b68
add activeChunk gc field
jeffmurphy Feb 7, 2022
a5f3abd
packing stage 1, commit contains debugging output
jeffmurphy Feb 16, 2022
46709f4
add instrumentation to runtime
jeffmurphy Feb 16, 2022
cae77d7
packing
jeffmurphy Feb 22, 2022
a832293
debug output
jeffmurphy Feb 22, 2022
86151eb
stage2
jeffmurphy Feb 27, 2022
56ebd81
disable debug output
jeffmurphy Feb 27, 2022
03b3b1d
prevent packing unless in same sw-period
jeffmurphy Mar 2, 2022
ba74cfb
ticks in micros
jeffmurphy Mar 26, 2022
37783dc
rtems changes
jeffmurphy Mar 27, 2022
1f90392
rtems
jeffmurphy Mar 28, 2022
d169e71
rtems
jeffmurphy Mar 29, 2022
28eafb9
lock debugging
jeffmurphy Apr 5, 2022
23b8b59
lock debug, instrumentation
jeffmurphy Apr 11, 2022
3b518bf
rework gc-check to be just a ccall. more lock debug
jeffmurphy Apr 12, 2022
163bc1f
lock debugging, instrumentation
jeffmurphy Apr 14, 2022
d3bcb7c
disable debugging, add more instrumentation
jeffmurphy Apr 14, 2022
05647c9
rtlinux - implement spinsleep
jeffmurphy Apr 20, 2022
063fbb2
indent
jeffmurphy Apr 30, 2022
f6d8e90
mods to adapt cdsml for SB-packing
jeffmurphy Feb 24, 2023
439dc29
docker
jeffmurphy Feb 24, 2023
fb1d590
cdsml rt sched changes
jeffmurphy Feb 28, 2023
1699085
add timing measurements to cd funcs
jeffmurphy Feb 28, 2023
8011aef
atomic begin/end prims call cfunc now
jeffmurphy Mar 2, 2023
a646408
wrap atomic debug statements
jeffmurphy Mar 2, 2023
93fd2d7
merging notes
jeffmurphy Mar 4, 2023
1a09bf6
64bit
jeffmurphy Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
ub/rtems/thread-message/message
runtime/constants-rtems/waf
ub/rtems/ratemono/.lock-waf_linux2_build
ub/rtems/ratemono/build/
ub/rtems/ratemono/waf
ub/rtems/two-threads/two-threads
ub/rtems/two-threads/two-threads.0.c.orig
ub/rtems/two-threads/two-threads.3.c
ub/rtems/two-threads/two-threads.3.c.orig
ub/rtlinux/deadline
ub/rtlinux/periodic
ub/rtems/two-threads/.lock-waf_linux2_build
ub/rtems/two-threads/waf
ub/rtems/two-threads/build
ub/rtems/justprint/.lock-waf_linux2_build
ub/rtems/justprint/waf
ub/rtems/justprint/build
Expand Down
16 changes: 16 additions & 0 deletions CDSml/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
RTML=/home/jcmurphy/RTMLton/build/bin/mlton

build:
$(RTML) -debug false -keep g -default-ann 'allowFFI true' -const 'Exn.keepHistory false' runCD.mlb

dbgbuild:
$(RTML) -debug true -keep g -default-ann 'allowFFI true' -const 'Exn.keepHistory false' runCD.mlb

testrun:
sudo ./runCD @MLton lower-bound 40 upper-bound 200 hpercent $(HPERC) rtthreads true max-heap $(HEAP) packingstage1 false packingstage2 false --

collect:
sudo ./runCD @MLton lower-bound 40 upper-bound 200 hpercent $(HPERC) rtthreads true max-heap $(HEAP) packingstage1 false packingstage2 false -- 2> $(RUN)-pack0.txt
sudo ./runCD @MLton lower-bound 40 upper-bound 200 hpercent $(HPERC) rtthreads true max-heap $(HEAP) packingstage1 true packingstage2 false -- 2> $(RUN)-pack1.txt
sudo ./runCD @MLton lower-bound 40 upper-bound 200 hpercent $(HPERC) rtthreads true max-heap $(HEAP) packingstage1 true packingstage2 true -- 2> $(RUN)-pack2.txt

14 changes: 4 additions & 10 deletions CDSml/driver-read-from-file.sml
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,22 @@ struct

fun loop_framesim ([],i,frameBuf) = if not (i=maxFrames) then loop_framesim(frameBuf,i,frameBuf) else ()
| loop_framesim(x::xs,i,frameBuf) = if not(i = maxFrames) then (Array.update(ts,i,Time.toMicroseconds (Time.now()));
(*print(IntInf.toString(Array.sub(ts,i))^"\n"); *)
print(IntInf.toString(Array.sub(ts,i))^"\n");
TransientDetector.TRANSIENTDETECTOR_run(x) ;



Array.update(tc,i,Time.toMicroseconds(Time.now ()) );
(*print(IntInf.toString(Time.toMicroseconds(Time.now()))^"\n");*)
print(IntInf.toString(Time.toMicroseconds(Time.now()))^"\n");
maybeSleep (Array.sub(ts,i));
loop_framesim(xs,(i+1),frameBuf) )
else
()
in
(*print (Int.toString(List.length(maxFrames)))*)
print (Int.toString(maxFrames)^"\n");
loop_framesim(frameBuffer, 0,frameBuffer);

(*printArray(ts);*)

populateIdealTime(Array.sub(ts,0));


populateIdealTime(Array.sub(ts,0));
(benchmarkCD ts tc tr)

end;


Expand Down
117 changes: 104 additions & 13 deletions CDSml/driver.sml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
open MLton.PrimThread

structure Driver =
struct

(* sched_runtime <= sched_deadline <= sched_period *)
val runtime = 12 * 1000000 (* 22 s *)
val deadline = 13 * 1000000 (* 22 s *)
val period = 14 * 1000000 (* 22 s *)




fun printit2 s = ()
fun printit s = print (Int.toString(getMyPriority ())^"] "^s^"\n")
fun gettime () = get_ticks_since_boot ()



structure Driver =
struct

(*To do read properly from file*)
datatype for = to of int * int
Expand Down Expand Up @@ -567,20 +579,22 @@ Frames.createFrame( 40, Array.fromList( [ "plane0","plane1","plane2","plane3","p






val starttime = ref (gettime ())
val stoptime = ref (gettime ())

fun loop ([],i,frameBuf) = if not (i=maxFrames) then loop(frameBuf,i,frameBuf) else ()
| loop(x::xs,i,frameBuf) = if not(i = maxFrames) then (Array.update(ts,i,Time.toMicroseconds (Time.now()));
(*print(IntInf.toString(Array.sub(ts,i))^"\n"); *)
starttime := gettime ();
TransientDetector.TRANSIENTDETECTOR_run(x) ;



stoptime := gettime ();
printit ("Driver: TRANSIENTDETECTOR_run: runtime "^Real.toString(Real.-(!stoptime, !starttime)));
Array.update(tc,i,Time.toMicroseconds(Time.now ()) );
(*print(IntInf.toString(Time.toMicroseconds(Time.now()))^"\n");*)
maybeSleep (Array.sub(ts,i));
(*maybeSleep (Array.sub(ts,i)); *)
printit("Wait for next period..");
wait_for_next_period false;
printit("awake for next period..");
loop(xs,(i+1),frameBuf) )
else
()
Expand Down Expand Up @@ -612,10 +626,87 @@ val rec loop =
| n => ((*print ("loop" ^ Int.toString(n) ^"\n");*) delay 50000000; loop (n - 1))


(*val _ = (PThread.spawn(fn () => Driver.main());PThread.spawn(fn () => loop
* 10); PThread.run())*)

val _ = Driver.main();
val _ = pspawn (
fn () => let
val _ = set_schedule (runtime, deadline, period, 2)
val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
while true do (
starttime := gettime ();
Driver.main();
stoptime := gettime ();
printit ("Driver[2]: runtime "^Real.toString(Real.-(!stoptime, !starttime)))
)
end, 2)

val _ = pspawn (
fn () => let
val _ = set_schedule (runtime, deadline, period, 2)
val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
while true do (
starttime := gettime ();
Driver.main();
stoptime := gettime ();
printit ("Driver[3]: runtime "^Real.toString(Real.-(!stoptime, !starttime)))
)
end, 3)

(*
val _ = pspawn (
fn () => let
val _ = set_schedule (runtime, deadline, period, 2)
val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
while true do (
starttime := gettime ();
Driver.main();
stoptime := gettime ();
printit ("Driver[4]: runtime "^Real.toString(Real.-(!stoptime, !starttime)))
)
end, 4)

val _ = pspawn (
fn () => let
val _ = set_schedule (runtime, deadline, period, 2)
val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
while true do (
starttime := gettime ();
Driver.main();
stoptime := gettime ();
printit ("Driver[5]: runtime "^Real.toString(Real.-(!stoptime, !starttime)))
)
end, 5)
*)

val _ = let
val iteration = ref 0
in
while true do (
printit ("main: running #"^Int.toString(!iteration));
OS.Process.sleep (Time.fromMicroseconds 10000000);
iteration := !iteration + 1;
schedule_yield false;
if (!iteration > 3) then (
(* dump_instrument_stderr 0;
dump_instrument_stderr 1;
dump_instrument_stderr 2;
dump_instrument_stderr 3; *)
dump_instrument_counter_stderr 0;
dump_instrument_counter_stderr 1;
dump_instrument_counter_stderr 2;
dump_instrument_counter_stderr 3;
OS.Process.terminate(OS.Process.success)
) else ();
()
)
end

(*Run with rtobj 5 for RTMLton*)

Expand Down
22 changes: 22 additions & 0 deletions CDSml/pincpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -x
#
# use this to pin deadline scheduled tasks
# to cpu0 in rtlinux

mkdir -p /dev/cpuset/cpu0
mount -t cgroup -o cpuset cpuset /dev/cpuset

echo 0 > /dev/cpuset/cpu0/cpuset.cpus
echo 0 > /dev/cpuset/cpu0/cpuset.mems
echo 1 > /dev/cpuset/cpuset.cpu_exclusive
echo 0 > /dev/cpuset/cpuset.sched_load_balance
echo 1 > /dev/cpuset/cpu0/cpuset.cpu_exclusive
echo 1 > /dev/cpuset/cpu0/cpuset.mem_exclusive

echo $$ > /dev/cpuset/cpu0/tasks
echo ./runCD @MLton lower-bound 40 upper-bound 200 hpercent 0.9 rtthreads true max-heap $3 packingstage1 $1 packingstage2 $2 --
bash

#sleep 10
#exec ./runCD @MLton lower-bound 40 upper-bound 200 hpercent 0.9 rtthreads true max-heap $3 packingstage1 $1 packingstage2 $2 --

4 changes: 2 additions & 2 deletions CDSml/runCD.mlb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ voxel.sml
reducer.sml
collision.sml
transientdetector.sml
(*driver.sml*)
driver-read-from-file.sml
driver.sml
(* driver-read-from-file.sml *)
36 changes: 22 additions & 14 deletions CDSml/transientdetector.sml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

open MLton.PrimThread




fun printit s = ()
fun printit2 s = print (Int.toString(getMyPriority ())^"] "^s^"\n")
fun gettime () = get_ticks_since_boot ()


structure StateTable =
struct


type t = string * Pos.t ref;

val table : t list ref = ref [];
Expand Down Expand Up @@ -141,11 +144,15 @@ struct
| printcheck (x :: xs) = print("Check list i length "^Int.toString(List.length(x))^"\n")

val ls = map determineCollisions check
val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
(*print("check length " ^ Int.toString(List.length(check))^"\n");*)
(*printcheck check;
print ("Collision length "^ Int.toString(List.length(ls)) ^"\n");*)
c @ ls
stoptime := gettime ();
printit ("lookforCollisions: runtime "^Real.toString(Real.-(!stoptime, !starttime)));
c @ ls
end


Expand Down Expand Up @@ -182,9 +189,13 @@ struct
fun TRANSIENTDETECTOR_createMotions(currentFrame) =
let
val mo : Motion.t list ref= ref []

val starttime = ref (gettime ())
val stoptime = ref (gettime ())
in
starttime := gettime ();
for (0 to (Frames.getPlaneCnt(currentFrame)-1)) (fn i => mo := !mo @ [TCM(i,currentFrame)]);
stoptime := gettime ();
printit ("TRANSIENTDETECTOR_createMotions: runtime "^Real.toString(Real.-(!stoptime, !starttime)));
!mo
end;

Expand All @@ -194,8 +205,9 @@ struct
fun TRANSIENTDETECTOR_run(currentFrame) =
let
val motions : Motion.t list = TRANSIENTDETECTOR_createMotions(currentFrame);

val collisions = lookforCollisions(motions)
val collisions = lookforCollisions(motions)
val starttime = ref (gettime ())
val stoptime = ref (gettime ())

fun printResults ([],index) = ()
| printResults (c :: tl,index) = (print("CD Collision" ^ Int.toString(index) ^ "occured at location " ^ Pos.getString(Collision.getLocation(c)) ^
Expand All @@ -205,15 +217,11 @@ struct
in
(*(*Motion.printListOfMotions(motions);*)print ("CD detected " ^ Int.toString(List.length(collisions)) ^ " collisions \n");
printResults(collisions,0)
*)()
*)
stoptime := gettime ();
printit ("TRANSIENTDETECTOR_run: runtime "^Real.toString(Real.-(!stoptime, !starttime)));
()
end;

end








5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM i386/ubuntu
RUN apt update -y
RUN apt upgrade -y
RUN apt install -y gcc libgmp-dev make smlnj patch mlton
CMD ["/bin/bash"]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,9 @@ rpms:
| $(GZIP) >"$(SOURCEDIR).tgz"
rm -rf "$(SOURCEDIR)"
rpm -ba --quiet --clean "$(TOPDIR)/SPECS/mlton.spec"

docker-build:
docker build -t rtmlton32_intel .

docker-run:
docker run -it -e DISPLAY=$(shell hostname):0 -v /Users/jcmurphy/git/cse/CSE/rtml-apps:/apps -v "$(shell pwd)":/work -v /tmp/.X11-unix:/tmp/.X11-unix rtmlton32_intel /bin/bash
2 changes: 1 addition & 1 deletion basis-library/mlton/exn.sml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ structure MLtonExn =
; Exit.halt Exit.Status.failure
; raise Fail "MLton.Exn.wrapHandler")
val defaultHandler = fn exn =>
(message (concat ["unhandled exception: ", exnMessage exn, "\n"])
(message (concat ["[basis-library/mlton/exn.sml] unhandled exception: ", exnMessage exn, "\n"])
; (case history exn of
[] => ()
| l =>
Expand Down
Loading