Cleanup
authorCafe <cafe@not.applicable>
Fri, 28 Jul 2017 00:00:00 +0000 (00:00 +0000)
committerCafe <cafe@not.applicable>
Fri, 28 Jul 2017 20:18:31 +0000 (20:18 +0000)
memory.c
memory.h
re.c

index 9819704a5d5ab83956ecbe4dea41860589fd4f30..6a9bc48f9df6c141d1c74cd84518ea51d645dda6 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -31,4 +31,9 @@ void gfree(void* ptr)
        /* TODO */
 }
 
+/* Dirty hack but useful for testing */
 
+void sync_cbma(int fd)
+{
+       sync_gpu(fd, (uint8_t*) cbma_top, cbma_top, cbma_bottom - cbma_top);
+}
index 06281392887fda9252be116b36001dab6152807d..de9b7b511299c538c1ba1866f314d597bf39b4b3 100644 (file)
--- a/memory.h
+++ b/memory.h
@@ -3,3 +3,4 @@
 void init_cbma(int fd);
 void* galloc(size_t sz);
 void gfree(void* ptr);
+void sync_cbma(int fd);
diff --git a/re.c b/re.c
index 2a07133a11ba85789d54239368045eadd5948374..654d2b077b9b22e45ca090235ecf65e19dfb5e02 100644 (file)
--- a/re.c
+++ b/re.c
 
 int atom_count = 0;
 
+struct base_dependency no_dependency = {
+       .atom_id = 0,
+       .dependency_type = BASE_JD_DEP_TYPE_INVALID
+};
+
 struct job_descriptor_header* set_value_helper(int fd, uint64_t out) {
        void* packet = galloc(sizeof(struct job_descriptor_header) +
                        sizeof(struct payload_set_value));
@@ -112,11 +117,6 @@ uint32_t job_chain_fragment(int fd, uint64_t framebuffer,
        memcpy(packet + sizeof(header), &payload, sizeof(payload));
        sync_gpu(fd, packet, (uint32_t) packet, sizeof(header) + sizeof(payload));
 
-       struct base_dependency depNoDep = {
-               .atom_id = 0,
-               .dependency_type = BASE_JD_DEP_TYPE_INVALID
-       };
-
        struct base_dependency depTiler = {
                .atom_id = atom_count /* last one */,
                .dependency_type = BASE_JD_DEP_TYPE_DATA
@@ -134,12 +134,10 @@ uint32_t job_chain_fragment(int fd, uint64_t framebuffer,
                .core_req = BASE_JD_REQ_EXTERNAL_RESOURCES | BASE_JD_REQ_FS,
                .atom_number = ++atom_count,
                .prio = BASE_JD_PRIO_MEDIUM,
-               .device_nr = 0
+               .device_nr = 0,
+               .pre_dep = { depTiler, no_dependency }
        };
 
-       job.pre_dep[0] = depTiler;
-       job.pre_dep[1] = depNoDep;
-
        submit_job(fd, job);
 
        return (uint32_t) packet;
@@ -390,11 +388,6 @@ uint32_t job_chain_vertex_tiler(int fd,
        vertex->job_dependency_index_2 = set->job_index;
        tiler->job_dependency_index_1 = vertex->job_index;
 
-       struct base_dependency depNoDep = {
-               .atom_id = 0,
-               .dependency_type = BASE_JD_DEP_TYPE_INVALID
-       };
-
        struct base_jd_atom_v2 job = {
                .jc = (uint32_t) set,
                .extres_list = NULL,
@@ -403,12 +396,10 @@ uint32_t job_chain_vertex_tiler(int fd,
                        | BASE_JD_REQ_CF | BASE_JD_REQ_COHERENT_GROUP,
                .atom_number = ++atom_count,
                .prio = BASE_JD_PRIO_MEDIUM,
-               .device_nr = 0
+               .device_nr = 0,
+               .pre_dep = { no_dependency, no_dependency }
        };
 
-       job.pre_dep[0] = depNoDep;
-       job.pre_dep[1] = depNoDep;
-
        submit_job(fd, job);
 
        return (uint32_t) tiler;
@@ -430,11 +421,6 @@ void job_chain_replay(int fd, uint32_t tiler_jc, uint32_t fragment_jc,
        payload->tiler_core_req = BASE_JD_REQ_T | BASE_JD_REQ_COHERENT_GROUP;
        payload->fragment_core_req = BASE_JD_REQ_FS;
 
-       struct base_dependency depNoDep = {
-               .atom_id = 0,
-               .dependency_type = BASE_JD_DEP_TYPE_INVALID
-       };
-
        struct base_dependency depFragment = {
                .atom_id = atom_count,
                .dependency_type = BASE_JD_DEP_TYPE_DATA
@@ -450,18 +436,13 @@ void job_chain_replay(int fd, uint32_t tiler_jc, uint32_t fragment_jc,
                .core_req = BASE_JD_REQ_EXTERNAL_RESOURCES | BASE_JD_REQ_SOFT_REPLAY,
                .atom_number = ++atom_count,
                .prio = BASE_JD_PRIO_LOW,
-               .device_nr = 0
+               .device_nr = 0,
+               .pre_dep = { depFragment, no_dependency }
        };
 
-       job.pre_dep[0] = depFragment;
-       job.pre_dep[1] = depNoDep;
-
        submit_job(fd, job);
 }
 
-extern uint32_t cbma_bottom;
-extern uint32_t cbma_top;
-
 int main()
 {
        int fd = open_kernel_module();
@@ -488,7 +469,6 @@ int main()
                0.0, 1.0, 0.0
        };
 
-
        uint32_t tiler_jc =
                job_chain_vertex_tiler(fd,
                        vertices, sizeof(vertices), CHAI_TRIANGLE_FAN,
@@ -499,7 +479,7 @@ int main()
        uint32_t fragment_jc = job_chain_fragment(fd, framebuffer, heap_free_address, scratchpad);
 
        job_chain_replay(fd, tiler_jc, fragment_jc, heap_free_address, framebuffer);
-       sync_gpu(fd, (uint8_t*) cbma_top, cbma_top, cbma_bottom - cbma_top);
+       sync_cbma(fd);
        flush_job_queue(fd);
 
        sleep(3);