Skip to content

Commit b211bc2

Browse files
Add ISPC GPU support
1 parent e356cd1 commit b211bc2

File tree

5 files changed

+220
-42
lines changed

5 files changed

+220
-42
lines changed

src/context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,14 @@ class EmitCtx {
167167
void setSYCLPrefix(std::string _val) { sycl_prefix = std::move(_val); }
168168
std::string getSYCLPrefix() { return sycl_prefix; }
169169

170+
void setISPCPrefix(std::string _val) { ispc_prefix = std::move(_val); }
171+
std::string getISPCPrefix() { return ispc_prefix; }
172+
170173
private:
171174
std::shared_ptr<EmitPolicy> emit_policy;
172175
bool ispc_types;
173176
bool sycl_access;
174177
std::string sycl_prefix;
178+
std::string ispc_prefix;
175179
};
176180
} // namespace yarpgen

src/data.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ std::string ScalarVar::getName(std::shared_ptr<EmitCtx> ctx) {
5050
std::string ret;
5151
if (!ctx->getSYCLPrefix().empty())
5252
ret = ctx->getSYCLPrefix();
53+
else if (!ctx->getISPCPrefix().empty())
54+
ret = ctx->getISPCPrefix();
5355
ret += Data::getName(ctx);
5456
if (ctx->useSYCLAccess())
5557
ret += "[0]";
@@ -123,6 +125,17 @@ std::shared_ptr<Array> Array::create(std::shared_ptr<PopulateCtx> ctx,
123125
return new_array;
124126
}
125127

128+
std::string Array::getName(std::shared_ptr<EmitCtx> ctx) {
129+
if (!ctx)
130+
ERROR("Can't give a name without a context");
131+
132+
std::string ret;
133+
if (!ctx->getISPCPrefix().empty())
134+
ret = ctx->getISPCPrefix();
135+
ret += Data::getName(ctx);
136+
return ret;
137+
}
138+
126139
void Iterator::setParameters(std::shared_ptr<Expr> _start,
127140
std::shared_ptr<Expr> _end,
128141
std::shared_ptr<Expr> _step) {

src/data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class Array : public Data {
126126

127127
Array(std::string _name, const std::shared_ptr<ArrayType> &_type,
128128
IRValue _val);
129+
std::string getName(std::shared_ptr<EmitCtx> ctx) override;
129130
IRValue getInitValues() { return init_vals; }
130131
array_val_t getCurrentValues() { return cur_vals; }
131132
void setValue(IRValue _val, std::deque<size_t> &span,

0 commit comments

Comments
 (0)