Skip to content

Commit

Permalink
Merge branch 'master' of github.com:halide/Halide
Browse files Browse the repository at this point in the history
  • Loading branch information
jrk committed May 24, 2013
2 parents 2526faa + c8f4c65 commit 3b54fcd
Show file tree
Hide file tree
Showing 22 changed files with 458 additions and 236 deletions.
5 changes: 4 additions & 1 deletion cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ TESTS = $(shell ls test/*.cpp)
ERROR_TESTS = $(shell ls test/error/*.cpp)

# TODO: move this implementation into Makefile.tests which contains a .NOTPARALLEL rule?
tests: $(TESTS:test/%.cpp=test_%) $(ERROR_TESTS:test/error/%.cpp=error_%)
tests: build_tests run_tests

run_tests: $(TESTS:test/%.cpp=test_%) $(ERROR_TESTS:test/error/%.cpp=error_%)
build_tests: $(TESTS:test/%.cpp=$(BIN_DIR)/test_%) $(ERROR_TESTS:test/error/%.cpp=$(BIN_DIR)/error_%)

$(BIN_DIR)/test_internal: test/internal.cpp $(BIN_DIR)/libHalide.so
$(CXX) $(CXX_FLAGS) $< -Isrc -L$(BIN_DIR) -lHalide -lpthread -ldl -o $@
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Argument {
/** If this is a scalar parameter, then this is its type */
Type type;

Argument() {}
Argument() : is_buffer(false) {}
Argument(const std::string &_name, bool _is_buffer, Type _type) :
name(_name), is_buffer(_is_buffer), type(_type) {}
};
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ map<string, Region> compute_regions_touched(Stmt s, bool consider_calls, bool co
s.accept(&r);
map<string, Region> regions;
for (map<string, vector<Interval> >::iterator iter = r.regions.begin();
iter != r.regions.end(); iter++) {
iter != r.regions.end(); ++iter) {
Region region;
const vector<Interval> &box = iter->second;
for (size_t i = 0; i < box.size(); i++) {
Expand Down
12 changes: 8 additions & 4 deletions cpp/src/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ using std::stack;
#define InitializeNVPTXTarget() InitializeTarget(NVPTX)

CodeGen::CodeGen() :
module(NULL), function(NULL), context(NULL),
module(NULL), owns_module(false),
function(NULL), context(NULL),
builder(NULL),
value(NULL), buffer_t(NULL) {
value(NULL),
void_t(NULL), i1(NULL), i8(NULL), i16(NULL), i32(NULL), i64(NULL),
f16(NULL), f32(NULL), f64(NULL),
buffer_t(NULL) {

// Initialize the targets we want to generate code for which are enabled
// in llvm configuration
Expand Down Expand Up @@ -1024,7 +1028,7 @@ void CodeGen::visit(const Call *op) {
if (op->name == "debug to file") {
assert(op->args.size() == 9);
const Call *filename = op->args[0].as<Call>();
const Call *func = op->args[1].as<Call>();
const Load *func = op->args[1].as<Load>();
assert(func && filename && "Malformed debug_to_file node");
// Grab the function from the initial module
llvm::Function *debug_to_file = module->getFunction("halide_debug_to_file");
Expand Down Expand Up @@ -1343,7 +1347,7 @@ void CodeGen::visit(const For *op) {
do_par_for->setDoesNotAlias(4);
//do_par_for->setDoesNotCapture(4);
ptr = builder->CreatePointerCast(ptr, i8->getPointerTo());
vector<Value *> args = vec((Value *)function, min, extent, ptr);
vector<Value *> args = vec<Value *>(function, min, extent, ptr);
log(4) << "Creating call to do_par_for\n";
builder->CreateCall(do_par_for, args);

Expand Down
14 changes: 7 additions & 7 deletions cpp/src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ void CodeGen_ARM::visit(const Div *op) {
// Do the shift (add 8 or 16 to narrow back down)
if (op->type == Int(32, 2) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -32);
val = call_intrin(narrower, "vshiftn.v2i32", vec(wide_val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v2i32", vec<Value *>(wide_val, shift_amount));
} else if (op->type == Int(16, 4) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -16);
val = call_intrin(narrower, "vshiftn.v4i16", vec(wide_val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v4i16", vec<Value *>(wide_val, shift_amount));
} else if (op->type == Int(8, 8) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -8);
val = call_intrin(narrower, "vshiftn.v8i8", vec(wide_val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v8i8", vec<Value *>(wide_val, shift_amount));
} else {
Constant *shift_amount = ConstantInt::get(wider, (shift + op->type.bits));
val = builder->CreateLShr(wide_val, shift_amount);
Expand Down Expand Up @@ -649,13 +649,13 @@ void CodeGen_ARM::visit(const Div *op) {
// Narrow
if (op->type == UInt(32, 2) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -32);
val = call_intrin(narrower, "vshiftn.v2i32", vec(val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v2i32", vec<Value *>(val, shift_amount));
} else if (op->type == UInt(16, 4) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -16);
val = call_intrin(narrower, "vshiftn.v4i16", vec(val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v4i16", vec<Value *>(val, shift_amount));
} else if (op->type == UInt(8, 8) && shift == 0) {
Constant *shift_amount = ConstantInt::get(wider, -8);
val = call_intrin(narrower, "vshiftn.v8i8", vec(val, (Value *)shift_amount));
val = call_intrin(narrower, "vshiftn.v8i8", vec<Value *>(val, shift_amount));
} else {
int shift_bits = op->type.bits;
// For methods 0 and 1, we can do the final shift here too
Expand Down Expand Up @@ -939,7 +939,7 @@ void CodeGen_ARM::visit(const Store *op) {
return;
}

if (ramp && is_one(ramp->stride) &&
if (is_one(ramp->stride) &&
call && call->name == "interleave vectors") {
assert(call->args.size() == 2 && "Wrong number of args to interleave vectors");
vector<Value *> args(call->args.size() + 2);
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/CodeGen_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,10 @@ void CodeGen_C::visit(const Allocate *op) {
do_indent();
stream << print_type(op->type) << ' ';

// For sizes less than 32k, do a stack allocation
// For sizes less than 8k, do a stack allocation
bool on_stack = false;
int stack_size = 0;
if (const IntImm *sz = op->size.as<IntImm>()) {
stack_size = sz->value;
on_stack = stack_size <= 32*1024;
on_stack = sz->value <= 8*1024;
}

if (on_stack) {
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/CodeGen_PTX_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ void CodeGen_PTX_Dev::compile(Stmt stmt, std::string name, const std::vector<Arg
builder->CreateBr(body_block);

// Add the nvvm annotation that it is a kernel function.
MDNode *mdNode = MDNode::get(*context, vec((Value*)function,
(Value*)MDString::get(*context, "kernel"),
(Value*)ConstantInt::get(i32, 1)));
MDNode *mdNode = MDNode::get(*context, vec<Value *>(function,
MDString::get(*context, "kernel"),
ConstantInt::get(i32, 1)));
module->getOrInsertNamedMetadata("nvvm.annotations")->addOperand(mdNode);


Expand Down
Loading

0 comments on commit 3b54fcd

Please sign in to comment.