Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO_NOT_MERGE] Ispc dev temp #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ CMakeCache.txt
doc

apps/tensor_times_vector/tensor_times_vector

.cache
.vscode
compile_commands.json
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ project(taco
LANGUAGES C CXX
)
option(CUDA "Build for NVIDIA GPU (CUDA must be preinstalled)" OFF)
option(ISPC "Build for Intel ISPC Compiler (ISPC Compiler must be preinstalled)" OFF)
option(PYTHON "Build TACO for python environment" OFF)
option(OPENMP "Build with OpenMP execution support" OFF)
option(COVERAGE "Build with code coverage analysis" OFF)
set(TACO_FEATURE_CUDA 0)
set(TACO_FEATURE_ISPC 0)
set(TACO_FEATURE_OPENMP 0)
set(TACO_FEATURE_PYTHON 0)
if(CUDA)
Expand All @@ -22,6 +24,11 @@ if(CUDA)
add_definitions(-DCUDA_BUILT)
set(TACO_FEATURE_CUDA 1)
endif(CUDA)
if(ISPC)
message("-- Searching for ISPC Installation")
add_definitions(-DISPC_BUILT)
set(TACO_FEATURE_ISPC 1)
endif(ISPC)
if(OPENMP)
message("-- Will use OpenMP for parallel execution")
add_definitions(-DUSE_OPENMP)
Expand Down
1 change: 1 addition & 0 deletions include/taco/codegen/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Module {

private:
std::stringstream source;
std::stringstream additional_source;
std::stringstream header;
std::string libname;
std::string tmpdir;
Expand Down
12 changes: 12 additions & 0 deletions include/taco/cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
#define CUDA_BUILT false
#endif

#ifndef ISPC_BUILT
#define ISPC_BUILT false
#endif

namespace taco {

/// Functions used by taco to interface with ISPC
bool should_use_ISPC_codegen();
void set_ISPC_codegen_enabled(bool enabled);
bool is_ISPC_code_stream_enabled();
void set_ISPC_code_stream_enabled(bool enabled);


/// Functions used by taco to interface with CUDA (especially unified memory)
/// Check if should use CUDA codegen
bool should_use_CUDA_codegen();
Expand Down
2 changes: 2 additions & 0 deletions include/taco/index_notation/transformations.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ IndexStmt parallelizeOuterLoop(IndexStmt stmt);
*/
IndexStmt reorderLoopsTopologically(IndexStmt stmt);

IndexStmt justTraverseThroughTheIndexStmt(IndexStmt stmt);

/**
* Performs scalar promotion so that reductions are done by accumulating into
* scalar temporaries whenever possible.
Expand Down
2 changes: 1 addition & 1 deletion include/taco/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ struct Switch : public StmtNode<Switch> {
static const IRNodeType _type_info = IRNodeType::Switch;
};

enum class LoopKind {Serial, Static, Dynamic, Runtime, Vectorized, Static_Chunked};
enum class LoopKind {Serial, Static, Dynamic, Runtime, Vectorized, Static_Chunked, Foreach, Mul_Thread, Init};

/** A for loop from start to end by increment.
* A vectorized loop will require the increment to be 1 and the
Expand Down
3 changes: 3 additions & 0 deletions include/taco/ir/ir_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class IRPrinter : public IRVisitorStrict {
public:
IRPrinter(std::ostream& stream);
IRPrinter(std::ostream& stream, bool color, bool simplify);
IRPrinter(std::ostream& stream, std::ostream& stream2, bool color, bool simplify);
virtual ~IRPrinter();

void setColor(bool color);
Expand Down Expand Up @@ -72,6 +73,7 @@ class IRPrinter : public IRVisitorStrict {
virtual void visit(const Break*);

std::ostream &stream;
std::ostream &stream2;
int indent;
bool color;
bool simplify;
Expand Down Expand Up @@ -109,6 +111,7 @@ class IRPrinter : public IRVisitorStrict {
void doIndent();
void printBinOp(Expr a, Expr b, std::string op, Precedence precedence);
bool needsParentheses(Precedence precedence);
void sendToStream(std::stringstream &stream);

std::string keywordString(std::string);
std::string commentString(std::string);
Expand Down
2 changes: 1 addition & 1 deletion include/taco/ir_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace taco {
/// ParallelUnit::GPUWarp can be optionally used to allow for GPU warp-level primitives
/// ParallelUnit::GPUThread causes for every iteration to be executed on a separate GPU thread
enum class ParallelUnit {
NotParallel, DefaultUnit, GPUBlock, GPUWarp, GPUThread, CPUThread, CPUVector, CPUThreadGroupReduction, GPUBlockReduction, GPUWarpReduction
NotParallel, DefaultUnit, GPUBlock, GPUWarp, GPUThread, CPUThread, CPUVector, CPUThreadGroupReduction, GPUBlockReduction, GPUWarpReduction, CPUSimd, CPUSpmd
};
extern const char *ParallelUnit_NAMES[];

Expand Down
3 changes: 3 additions & 0 deletions include/taco/lower/lowerer_impl_imperative.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,13 @@ class LowererImplImperative : public LowererImpl {

bool emitUnderivedGuards = true;

int loopDepth = 0;
int inParallelLoopDepth = 0;

std::map<ParallelUnit, ir::Expr> parallelUnitSizes;
std::map<ParallelUnit, IndexVar> parallelUnitIndexVars;
std::map<int, ParallelUnit> forUnits; // <loopdepth, ParallelUnit>
std::map<TensorVar,int> whereTempsWithLoopDepth;

/// Keep track of what IndexVars have already been defined
std::set<IndexVar> definedIndexVars;
Expand Down
22 changes: 22 additions & 0 deletions include/taco/util/strings.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
#ifndef TACO_UTIL_STRINGS_H
#define TACO_UTIL_STRINGS_H

#include "taco/cuda.h"
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <limits>

#include "taco/type.h"

// To get the value of a compiler macro variable
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)

namespace taco {
namespace util {

// /// Turn anything except floating points that can be written to a stream
// /// into a string.
// template <class T>
// typename std::enable_if<!std::is_floating_point<T>::value, std::string>::type
// toStringISPC(const T &val) {

// std::stringstream sstream;
// if (val == Int32) {
// sstream << "int32";
// }
// else if (val == Int64) {
// sstream << "int64";
// }
// else {
// sstream << val;
// }
// return sstream.str();
// }

/// Turn anything except floating points that can be written to a stream
/// into a string.
template <class T>
Expand Down
1 change: 1 addition & 0 deletions include/taco/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#define TACO_FEATURE_OPENMP @TACO_FEATURE_OPENMP@
#define TACO_FEATURE_PYTHON @TACO_FEATURE_PYTHON@
#define TACO_FEATURE_CUDA @TACO_FEATURE_CUDA@
#define TACO_FEATURE_ISPC @TACO_FEATURE_ISPC@

#endif /* TACO_VERSION_H */
Binary file added out/taco-uml/._taco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading