Revision c1885fc710ddebff3e50023e662e9f822a7f2a3d authored by Alexander Root on 04 December 2020, 00:14:07 UTC, committed by GitHub on 04 December 2020, 00:14:07 UTC
* Add shift_left fix for signed integers by possibly negative values + regression test

* add required condition on shift_left integer fix

* add type check to shift_left minimum condition

* fix constant folding of shifts with |b| >= type.bits() for types that allow overflow (failes correctness/simplify test)

* make regression tests use scoped bindings

* change condition in case int24/int48 proposal happens soon

* revert changes based on overflow expectations

* add more regression tests

* clarify comment

* add shift_left min handler for b only UB

* fix clang-tidy complaint

* relax shift_left of non-negative value constraint

* pull case outside of unnecessary preconditions

* fix clang-format complaint

* fix broken precondition

* add typecheck to possibly save a can_prove() call

* add easy-out type check to precondition

* Add descriptive comment to bug fix + add another early-exit precondition

Co-authored-by: Steven Johnson <srj@google.com>
1 parent 28f9aef
Raw File
Realization.cpp
#include "Realization.h"

#include "Buffer.h"
#include "Error.h"

namespace Halide {

/** The number of images in the Realization. */
size_t Realization::size() const {
    return images.size();
}

/** Get a const reference to one of the images. */
const Buffer<void> &Realization::operator[](size_t x) const {
    user_assert(x < images.size()) << "Realization access out of bounds\n";
    return images[x];
}

/** Get a reference to one of the images. */
Buffer<void> &Realization::operator[](size_t x) {
    user_assert(x < images.size()) << "Realization access out of bounds\n";
    return images[x];
}

/** Construct a Realization that refers to the buffers in an
 * existing vector of Buffer<> */
Realization::Realization(std::vector<Buffer<void>> &e)
    : images(e) {
    user_assert(!e.empty()) << "Realizations must have at least one element\n";
}

/** Call device_sync() for all Buffers in the Realization.
 * If one of the calls returns an error, subsequent Buffers won't have
 * device_sync called; thus callers should consider a nonzero return
 * code to mean that potentially all of the Buffers are in an indeterminate
 * state of sync.
 * Calling this explicitly should rarely be necessary, except for profiling. */
int Realization::device_sync(void *ctx) {
    for (auto &b : images) {
        int result = b.device_sync(ctx);
        if (result != 0) {
            return result;
        }
    }
    return 0;
}

}  // namespace Halide
back to top