-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.odin
73 lines (63 loc) · 1.78 KB
/
main.odin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//+private file
package main
import "core:fmt"
import "core:mem"
import rand "core:math/rand"
import "core:time"
check_memory_allocations :: proc(track: ^mem.Tracking_Allocator) {
if len(track.allocation_map) > 0 {
fmt.eprintf("=== %v allocations not freed: ===\n", len(track.allocation_map))
for _, entry in track.allocation_map {
fmt.eprintf("- %v bytes @ %v\n", entry.size, entry.location)
}
}
if len(track.bad_free_array) > 0 {
fmt.eprintf("=== %v incorrect frees: ===\n", len(track.bad_free_array))
for entry in track.bad_free_array {
fmt.eprintf("- %p @ %v\n", entry.memory, entry.location)
}
}
mem.tracking_allocator_destroy(track)
}
run_viz :: proc() {
// Viz Init
err := viz_init()
defer viz_deinit()
if err {
return
}
// Load test data
test_data, test_ok := load_mnist_data(MNIST_TEST_FILE_PATH, TEST_DATA_LEN)
defer delete(test_data)
if !test_ok {
fmt.println("Failed to read mnist test data file")
return
}
// Sim loop
frame_idx := 0
img_idx := 0
for {
defer frame_idx = (frame_idx + 1) % 15
if frame_idx == 0 {
img_idx = (img_idx + 1) % TEST_DATA_LEN
}
if is_viz_terminate() {
break
}
viz_update(&test_data[img_idx])
free_all(context.temp_allocator)
}
free_all(context.temp_allocator)
}
@private
main :: proc() {
// Debug mem track
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.allocator)
context.allocator = mem.tracking_allocator(&track)
defer check_memory_allocations(&track)
// seed rand
rand.reset(u64(time.to_unix_nanoseconds(time.now())))
// trian()
run_viz()
}