Branch data Line data Source code
1 : : /* StarPU --- Runtime system for heterogeneous multicore architectures.
2 : : *
3 : : * Copyright (C) 2009, 2010-2011, 2013 Université de Bordeaux 1
4 : : * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
5 : : *
6 : : * StarPU is free software; you can redistribute it and/or modify
7 : : * it under the terms of the GNU Lesser General Public License as published by
8 : : * the Free Software Foundation; either version 2.1 of the License, or (at
9 : : * your option) any later version.
10 : : *
11 : : * StarPU is distributed in the hope that it will be useful, but
12 : : * WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 : : *
15 : : * See the GNU Lesser General Public License in COPYING.LGPL for more details.
16 : : */
17 : :
18 : : #include <datawizard/footprint.h>
19 : : #include <starpu_hash.h>
20 : : #include <core/task.h>
21 : :
22 : 254259 : uint32_t _starpu_compute_buffers_footprint(struct starpu_perfmodel *model, enum starpu_perf_archtype arch, unsigned nimpl, struct _starpu_job *j)
23 : : {
24 [ + + ]: 254259 : if (j->footprint_is_computed)
25 : 221061 : return j->footprint;
26 : :
27 : 33198 : uint32_t footprint = 0;
28 : : unsigned buffer;
29 : :
30 : 33198 : struct starpu_task *task = j->task;
31 : :
32 [ + - ][ - + ]: 33198 : if (model && model->per_arch[arch][nimpl].size_base)
33 : 0 : {
34 : 0 : size_t size = model->per_arch[arch][nimpl].size_base(task, arch, nimpl);
35 : 0 : footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
36 : : }
37 [ + - ][ - + ]: 33198 : else if (model && model->size_base)
38 : 0 : {
39 : 0 : size_t size = model->size_base(task, nimpl);
40 : 0 : footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
41 : : }
42 : : else
43 : : {
44 [ + + ]: 73888 : for (buffer = 0; buffer < task->cl->nbuffers; buffer++)
45 : : {
46 [ - + ]: 40690 : starpu_data_handle_t handle = STARPU_TASK_GET_HANDLE(task, buffer);
47 : :
48 : 40690 : uint32_t handle_footprint = _starpu_data_get_footprint(handle);
49 : :
50 : 40690 : footprint = starpu_crc32_be(handle_footprint, footprint);
51 : : }
52 : : }
53 : :
54 : 33198 : j->footprint = footprint;
55 : 33198 : j->footprint_is_computed = 1;
56 : :
57 : 254259 : return footprint;
58 : : }
59 : :
60 : 72227 : uint32_t _starpu_compute_data_footprint(starpu_data_handle_t handle)
61 : : {
62 : 72227 : uint32_t interfaceid = (uint32_t)starpu_handle_get_interface_id(handle);
63 : :
64 [ - + ]: 72212 : STARPU_ASSERT(handle->ops->footprint);
65 : :
66 : 72212 : uint32_t handle_footprint = handle->ops->footprint(handle);
67 : :
68 : 72215 : return starpu_crc32_be(handle_footprint, interfaceid);
69 : : }
70 : :
71 : 0 : uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perf_archtype arch, unsigned nimpl)
72 : : {
73 : 0 : struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
74 : 0 : return _starpu_compute_buffers_footprint(model, arch, nimpl, j);
75 : : }
|