Repository navigation
Add DeepRM Packer scheduling policy #5
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
Merged
+120
−11
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //! Packer, the packing baseline of DeepRM (Mao et al., HotNets'16; the | ||
| //! `get_packer_action` agent of the reference code): among the (job, | ||
| //! machine) pairs that fit now, pick the one with the largest dot product of | ||
| //! the machine's free capacity at the current tick and the job's demand | ||
| //! vector: | ||
| //! | ||
| //! score = Σ_r free[r][now] · peak[r] | ||
| //! | ||
| //! Unlike `tetris` there is no normalization by capacity and only the current | ||
| //! tick of the machine is looked at (the fit check still covers the job's | ||
| //! whole duration). The demand vector is the job's per-resource peak, which | ||
| //! is DeepRM's constant `res_vec` for constant-demand jobs. Ties: first | ||
| //! machine, then oldest job (DeepRM: lowest slot index). With one machine | ||
| //! this is exactly DeepRM's Packer. | ||
| //! | ||
| //! The dot product is summed exactly in integers; it is stored as f32 by | ||
| //! `PairCache`, which is exact up to 2^24 (e.g. capacities up to ~2000 on | ||
| //! 2 resources), so ties are real ties for realistic capacities. | ||
| //! | ||
| //! Scores are cached across decisions (`PairCache`). | ||
| const model = @import("../../model.zig"); | ||
| const PairCache = @import("pair_cache.zig").PairCache; | ||
|
|
||
| fn score(_: void, st: *const model.State, s: usize, m: usize) f32 { | ||
| const peak = st.jobs.peakOf(s); | ||
| const mach = st.machines.get(m); | ||
| var acc: u64 = 0; | ||
| for (0..st.machines.layout.n_res) |r| { | ||
| acc += @as(u64, mach.resource(r)[0]) * @as(u64, peak[r]); | ||
| } | ||
| return @floatFromInt(acc); | ||
| } | ||
|
|
||
| pub const Packer = struct { | ||
| pub const name = "packer"; | ||
|
|
||
| cache: PairCache = .{}, | ||
|
|
||
| pub fn deinit(self: *Packer) void { | ||
| self.cache.deinit(); | ||
| } | ||
|
|
||
| pub fn decide(self: *Packer, st: *const model.State) model.Action { | ||
| self.cache.update(st, score, {}) catch @panic("packer: out of memory"); | ||
| return self.cache.pick(st, PairCache.noPen, {}); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.