ddemidov / vexcl

@@ -79,23 +79,29 @@
Loading
79 79
80 80
    std::vector<size_t> i(m);
81 81
    std::generate(i.begin(), i.end(), [n](){ return rand() % n; });
82 -
    std::sort(i.begin(), i.end());
83 -
    i.resize( std::unique(i.begin(), i.end()) - i.begin() );
84 82
85 -
    std::vector<double> data(i.size());
86 -
    vex::gather<double>  get(ctx, x.size(), i);
87 -
    vex::scatter<double> put(ctx, x.size(), i);
83 +
    for (int sorted = 0; sorted < 2; ++sorted) {
84 +
        if (sorted) {
85 +
            std::sort(i.begin(), i.end());
86 +
            i.resize( std::unique(i.begin(), i.end()) - i.begin() );
87 +
        }
88 88
89 -
    get(X, data);
89 +
        std::vector<double>  data(i.size());
90 +
        vex::gather<double>  get(ctx, x.size(), i);
91 +
        vex::scatter<double> put(ctx, x.size(), i);
90 92
91 -
    for(size_t p = 0; p < i.size(); ++p)
92 -
        BOOST_CHECK(data[p] == x[i[p]]);
93 +
        get(X, data);
93 94
94 -
    X = 0;
95 -
    put(data, X);
95 +
        for(size_t p = 0; p < i.size(); ++p)
96 +
            BOOST_CHECK(data[p] == x[i[p]]);
96 97
97 -
    for(size_t p = 0; p < i.size(); ++p)
98 -
        BOOST_CHECK(data[p] == x[i[p]]);
98 +
        vex::vector<double> Y(ctx, n);
99 +
        Y = 0;
100 +
        put(data, Y);
101 +
102 +
        for(size_t p = 0; p < i.size(); ++p)
103 +
            BOOST_CHECK(Y[i[p]] == x[i[p]]);
104 +
    }
99 105
}
100 106
101 107
BOOST_AUTO_TEST_CASE(std_sort_vex_vector)

@@ -48,41 +48,41 @@
Loading
48 48
    public:
49 49
        index_partition(
50 50
                const std::vector<backend::command_queue> &q,
51 -
                size_t size, std::vector<size_t> &indices
51 +
                size_t size, const std::vector<size_t> &indices
52 52
                )
53 -
            : queue(q), ptr(q.size() + 1, 0),
54 -
              idx(q.size()), val(q.size())
53 +
            : queue(q), ptr(q.size() + 1, 0)
55 54
        {
56 -
            assert(queue.size() == 1 || std::is_sorted(indices.begin(), indices.end()));
55 +
            if (queue.size() > 1 && !std::is_sorted(indices.begin(), indices.end())) {
56 +
                idx.resize(indices.size());
57 +
                ord.resize(indices.size());
58 +
59 +
                std::iota(ord.begin(), ord.end(), 0ul);
60 +
                std::sort(ord.begin(), ord.end(), [&indices](size_t i, size_t j){ return indices[i] < indices[j]; });
61 +
62 +
                std::vector<size_t> I(indices.size());
63 +
                for(size_t i = 0; i < indices.size(); ++i)
64 +
                    idx[i] = indices[ord[i]];
65 +
            } else {
66 +
                idx = indices;
67 +
            }
57 68
58 69
            std::vector<size_t> part = partition(size, queue);
59 70
            column_owner owner(part);
60 71
61 -
            for(auto i = indices.begin(); i != indices.end(); ++i) {
72 +
            for(auto i = idx.begin(); i != idx.end(); ++i) {
62 73
                size_t d = owner(*i);
63 74
                *i -= part[d];
64 75
                ++ptr[d + 1];
65 76
            }
66 77
67 78
            std::partial_sum(ptr.begin(), ptr.end(), ptr.begin());
68 -
69 -
            for(unsigned d = 0; d < queue.size(); d++) {
70 -
                if (size_t n = ptr[d + 1] - ptr[d]) {
71 -
                    val[d] = backend::device_vector<T>(queue[d], n, static_cast<const T*>(0));
72 -
                    idx[d] = backend::device_vector<size_t>(
73 -
                            queue[d], n, &indices[ptr[d]], backend::MEM_READ_ONLY);
74 -
                }
75 -
            }
76 -
77 -
            for(unsigned d = 0; d < queue.size(); d++)
78 -
                if (ptr[d + 1] - ptr[d]) queue[d].finish();
79 79
        }
80 80
81 81
    protected:
82 -
        std::vector<backend::command_queue>           queue;
83 -
        std::vector< size_t >                         ptr;
84 -
        std::vector< backend::device_vector<size_t> > idx;
85 -
        std::vector< backend::device_vector<T> >      val;
82 +
        std::vector<backend::command_queue> queue;
83 +
        std::vector< size_t > ptr;
84 +
        std::vector< size_t > idx;
85 +
        std::vector< size_t > ord;
86 86
};
87 87
88 88
} // namespace detail
@@ -98,7 +98,7 @@
Loading
98 98
         */
99 99
        gather(
100 100
                const std::vector<backend::command_queue> &q,
101 -
                size_t size, std::vector<size_t> indices
101 +
                size_t size, const std::vector<size_t> &indices
102 102
              ) : Base(q, size, indices)
103 103
        {}
104 104
@@ -111,18 +111,17 @@
Loading
111 111
112 112
            for(unsigned d = 0; d < Base::queue.size(); d++) {
113 113
                if (size_t n = Base::ptr[d + 1] - Base::ptr[d]) {
114 -
                    vector<T>      v(Base::queue[d], Base::val[d]);
115 -
                    vector<T>      s(Base::queue[d], src(d));
116 -
                    vector<size_t> i(Base::queue[d], Base::idx[d]);
117 -
118 -
                    v = permutation(i)(s);
119 -
120 -
                    Base::val[d].read(Base::queue[d], 0, n, &dst[Base::ptr[d]]);
114 +
                    auto s = src.map(d);
115 +
116 +
                    if (Base::ord.empty()) {
117 +
                        for(size_t i = Base::ptr[d]; i < Base::ptr[d+1]; ++i)
118 +
                            dst[i] = s[Base::idx[i]];
119 +
                    } else {
120 +
                        for(size_t i = Base::ptr[d]; i < Base::ptr[d+1]; ++i)
121 +
                            dst[Base::ord[i]] = s[Base::idx[i]];
122 +
                    }
121 123
                }
122 124
            }
123 -
124 -
            for(unsigned d = 0; d < Base::queue.size(); d++)
125 -
                if (Base::ptr[d + 1] - Base::ptr[d]) Base::queue[d].finish();
126 125
        }
127 126
    private:
128 127
        typedef detail::index_partition<T> Base;
@@ -139,7 +138,7 @@
Loading
139 138
         */
140 139
        scatter(
141 140
                const std::vector<backend::command_queue> &q,
142 -
                size_t size, std::vector<size_t> indices
141 +
                size_t size, const std::vector<size_t> &indices
143 142
              ) : Base(q, size, indices)
144 143
        {}
145 144
@@ -152,18 +151,16 @@
Loading
152 151
153 152
            for(unsigned d = 0; d < Base::queue.size(); d++) {
154 153
                if (size_t n = Base::ptr[d + 1] - Base::ptr[d]) {
155 -
                    Base::val[d].write(Base::queue[d], 0, n, &src[Base::ptr[d]]);
156 -
157 -
                    vector<T>      v(Base::queue[d], Base::val[d]);
158 -
                    vector<T>      s(Base::queue[d], dst(d));
159 -
                    vector<size_t> i(Base::queue[d], Base::idx[d]);
160 -
161 -
                    permutation(i)(s) = v;
154 +
                    auto v = dst.map(d);
155 +
                    if (Base::ord.empty()) {
156 +
                        for(size_t i = Base::ptr[d]; i < Base::ptr[d+1]; ++i)
157 +
                            v[Base::idx[i]] = src[i];
158 +
                    } else {
159 +
                        for(size_t i = Base::ptr[d]; i < Base::ptr[d+1]; ++i)
160 +
                            v[Base::idx[i]] = src[Base::ord[i]];
161 +
                    }
162 162
                }
163 163
            }
164 -
165 -
            for(unsigned d = 0; d < Base::queue.size(); d++)
166 -
                if (Base::ptr[d + 1] - Base::ptr[d]) Base::queue[d].finish();
167 164
        }
168 165
    private:
169 166
        typedef detail::index_partition<T> Base;
Files Coverage
tests 99.61%
vexcl 94.82%
CL/cl.hpp 85.20%
examples/devlist.cpp 94.59%
Project Totals (114 files) 95.37%
1430.1
TRAVIS_OS_NAME=linux
1430.3
TRAVIS_OS_NAME=linux
1430.9
TRAVIS_OS_NAME=osx
1430.7
TRAVIS_OS_NAME=osx

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading