louisjenkinscs / chapelcl Goto Github PK
View Code? Open in Web Editor NEWOpenCL Wrapper for Chapel
License: BSD 3-Clause "New" or "Revised" License
OpenCL Wrapper for Chapel
License: BSD 3-Clause "New" or "Revised" License
var kernel = new GPUKernel();
var x = kernel.createScalar("x", GPUVariableType.INT);
kernel.createCustomStmt(x.name + " = pow(random(), 2) % 3");
Something like the above can be used for when things get so complicated that you cannot actually rely on what we provide. It follows the 'multiresolution design philosophy' too!
Obtaining ideal workgroup size
size_t sz;
size_t retsz;
clGetKernelWorkGroupInfo(kernel, device_id, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, sizeof(sz), &sz, &retsz);
This document will be a placeholder for an official specification that will be followed when designing this library, and should provide a high-level description of the end-to-end compilation from Chapel symbolic variables, expressions, and statements down to OpenCL.
In Chapel, we provide what are referred to as 'symbolic' variables, in that they do not hold a concrete value, but more or less function as 'names' that you can create entire expressions and statements out of. For an example of a symbolic variable, think of some variable x
that you want to increment, x += 1
. The actual value of x
is not known until you run the program, as only then does it hold some concrete value. These symbolic variables are not concerned with what value x
holds before and after the increment, just that some variable x
gets incremented.
TODO: Discuss benefits and limitations, as well as code snippet
TODO: Discuss Scalars
TODO: Discuss Vectors
var arr; // TODO: Finalize design on how to create symbolic arrays
for a in arr {
// ...
}
var arr; // TODO: Finalize design on how to create symbolic arrays
forall a in arr {
// ...
}
TODO: Describe how we map down Chapel-idiomatic code to an AST
TODO: Describe how we map down AST to GPU kernel
It might be wiser to construct the AST on-the-fly, as then we do not need to store stringified output until we want to actually write it all out into the GPU kernel. It could be pretty interesting...
proc +(sym1 : GPUVariable, obj) {
// Initializer overloaded to take certain supported types
// Maybe even other GPUInstr types?
return GPUAddInstr(sym1, obj);
}
Could be rather promising, at the very least, for providing a framework for creating DSLs that allow you to make use of a high-level language like Chapel!
One big issue I can foresee if in the application of conditionals. For example...
var kernel = new GPUKernel();
var x = kernel.createScalar("x", GPUVariableType.INT);
var y = kernel.createScalar("y", GPUVariableType.INT);
var arr = kernel.createArray("arr", GPUVariableType.INT, 10);
for a in arr do a = if x > y then x else y;
The above clearly will not work. Why? Because how do we compare two variables without concrete values? We can only really generate the code we execute, and the goal is to not rely on the compiler for this kind of stuff.
I propose that instead of trying to figure out how to make this implicit, I can create an API to make this more explicit.
var kernel = new GPUKernel();
var x = kernel.createScalar("x", GPUVariableType.INT);
var y = kernel.createScalar("y", GPUVariableType.INT);
var arr = kernel.createArray("arr", GPUVariableType.INT, 10);
for a in arr {
var cond = kernel.createIfStmt(x > y);
cond.beginIfTrue();
a = x;
cond.beginFalse();
a = y;
cond.done();
};
I know, its not as cool-looking, but it would work. As well if we had better first-class function support, we'd have kernel.creatIfStmt(x > y, lambda () { a = x; }, lambda () { a = y; })
.
To introduce parallelism, things like 'get_global_idand
get_local_id`, etc., should be cached into some variable, or at least abstractly represented via some symbolic variable.
Support creating GPUVariable
of various types that match what the backend requires.
// Anonymous typed variable
var x : GPUVariable(int);
var y : GPUVariable(real);
// Named typed variables
var z : GPUVariable(int, name="z");
var arr : GPUArray(int, {1..10});
Slicing an array can be represented via overloading this
to take a range which can return a symbolic array view. This can work to support strided arrays as well!
Examples of programs can help to determine how I should structure/create my own library.
Helper kernels written in C can help provide insight on what kernels I should provide (they should be generated in my own library but available for composition to the user)
Layouts like these can be somewhat useful to look at.
Interesting stuff.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.