1 --- !ditz.rubyforge.org,2008-03-06/issue
2 title: Consider an appropriate API and implementation for backing store (--resident).
7 reporter: David Hilvert <dhilvert@auricle.dyndns.org>
10 creation_time: 2009-02-21 19:42:45.100645 Z
13 id: cd8cda126db604feda8a481b2022490311624cb9
15 - - 2009-02-21 19:42:46.053124 Z
16 - David Hilvert <dhilvert@auricle.dyndns.org>
19 - - 2009-02-21 19:57:42.252638 Z
20 - David Hilvert <dhilvert@auricle.dyndns.org>
23 Reasonable approaches might involve either passing a file (FILE *) from client
24 code or passing a function pointer for generation of temporary files (e.g.,
25 satisfied by tmpfile() or similar).
26 - - 2009-02-21 20:17:15.752238 Z
27 - David Hilvert <dhilvert@auricle.dyndns.org>
30 In particular, passing a file (FILE *) might be most appropriate for data
31 received from client code (e.g., frames), while using a temporary file
32 generator (perhaps specified in client code, or otherwise defaulting to
33 something like tmpfile()) might be most appropriate for images generated by the
36 Note also that file specifications might include byte or word offsets (so that,
37 e.g., PPM binary formats can be passed without copying or otherwise shuffling
39 - - 2009-02-21 20:38:02.649102 Z
40 - David Hilvert <dhilvert@auricle.dyndns.org>
43 Any variable pointing to a temporary file generator should probably be
44 contained within a client-associated object (e.g., an ale_context).
45 - - 2009-02-21 22:39:36.712462 Z
46 - David Hilvert <dhilvert@auricle.dyndns.org>
49 Note that transfers between backing store files and compute device memories
50 will probably occur largely within rendering code (and perhaps on load, in
51 cases where a loaded compute memory object is larger than resident_size).
53 In particular, renderers will probably be able to determine what patterns
54 of loading are necessary.
55 - - 2009-02-22 05:35:27.011928 Z
56 - David Hilvert <dhilvert@auricle.dyndns.org>
59 Consider that it might be worthwhile to have separate concepts of objects
60 resident in host memory and device memory, and also that it might be worthwhile
61 to have separate limits for sizes in these areas (perhaps also with limits per
62 device, in the case of multiple devices).
63 - - 2009-02-22 06:12:15.268113 Z
64 - David Hilvert <dhilvert@auricle.dyndns.org>
67 Note that various patterns of pixels could be used for loading and storage
68 (e.g., block-contiguous, arranged in a grid, or row-contiguous, arranged by
69 rows), and that the choice of pattern may be relevant for reducing explicit
70 load counts, as well as for cache behavior (and that such considerations extend
71 also to the current ALE code).
72 - - 2009-02-23 12:10:12.750096 Z
73 - David Hilvert <dhilvert@auricle.dyndns.org>
76 For the case of a memory hierarchy from files to host memory to device memory,
77 it might be appropriate to have (at least) three API functions, such as --
79 ale_image_set_cl(..., cl_mem)
81 ale_image_set_file(..., FILE *)
83 ale_image_set_host(..., void *)
84 - - 2009-02-25 12:02:50.223765 Z
85 - David Hilvert <dhilvert@auricle.dyndns.org>
88 A property could be added for determining what sort of backing should be used
89 for host memory. In particular, an option could be added for backing host
90 memory with a memory-mapped file (instead of backing it with swap). On the
91 other hand, it seems that explicit loads and stores from files will be
92 necessary, if swap performance in ALE is any indication, so that perhaps
93 implicit copied (as opposed to explicitly copied) backing for host memory is
94 not an especially pressing concern.
95 - - 2009-02-25 12:16:49.269339 Z
96 - David Hilvert <dhilvert@auricle.dyndns.org>
99 Analogously with ale_image_set_*, there should probably be multiple varieties
100 of return functions, such as:
110 ale_image_return_cl(...)
112 ale_image_return_file(...)
114 ale_image_return_host(...)
115 - - 2009-02-25 12:44:31.536957 Z
116 - David Hilvert <dhilvert@auricle.dyndns.org>
119 Rather than separate (_cl, _file, _host), returns could be handled via a
120 structure and union similar to:
133 ale_mem foo = ale_return(...);
135 Similarly, such a carrier could be used for initialization, as:
137 ale_image_set(..., ale_mem);
139 Helper functions (or macros) could also be devised, as
141 ale_mem am = host_to_ale(void *)
143 void *hm = ale_to_host(void *)
149 Of course, since such bundling and unbundling of assignments would be primarily
150 associated with the ale_image type, such operations could instead be directly
151 included within the type itself, so that no additional carrier structure would
153 - - 2009-02-25 12:57:51.415584 Z
154 - David Hilvert <dhilvert@auricle.dyndns.org>
157 In the case that return_*() functions are used, there should probably also be a
158 return_type() function, indicating what type of return is appropriate. I.e.,
164 ale_image_return_type(...)
165 - - 2009-02-27 16:43:09.761662 Z
166 - David Hilvert <dhilvert@auricle.dyndns.org>
169 Note that one advantage to using a return_type function in combination with
170 separate return_*() functions is that it allows determination of the return
171 type without involving any reference counting operations.
172 - - 2009-03-04 13:25:55.042007 Z
173 - David Hilvert <dhilvert@auricle.dyndns.org>
175 - Modified API for ale_return_* and ale_image_set_*, with accompanying ale_image_buffer_type().