-
Notifications
You must be signed in to change notification settings - Fork 33
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
TypeScript support #70
base: master
Are you sure you want to change the base?
Conversation
…eseven/node-opencl into feature/upgrade_to_NAN_2.8.0
…ntal OpenCL 2.1 CPU Only Platform
* return compiled program from clGetProgramInfo(cl.PROGRAM_BINARIES) * detect if a buffer is being unwrapped inside NoCLWrapper::Unwrap, and reinterpret_cast into the type if so * only pass programs with size > 0 to clCreateProgramFromBinary for nvidia
…h older node versions
Intermediate commit
@lu4 - picking this back up Does this preserve API compatibility with non-ts users? if not, can it be done in a way that does so, such as alt calls? |
Hi @lmeyerov, I'm having trouble with understanding what kind of compatibility are you asking about? Do you mean whether JavaScript developers would be able to use the provided api without the need of migrating to TypeScript? (If so than yes, they should have such ability, but this support might require couple of checks from my side and probably couple of updates. If this is the compatibility you are asking about then let me know)
|
Yes, exactly: -- can new node-opencl users use it without using typescript themselves? |
If both are a yes, will help test + land soon after #69 . . If a no... bet we can figure it out :) |
-- can new node-opencl users use it without using typescript themselves? -- were there no public api changes, so existing node-opencl users can keep using it with no changes?
Maybe there's something else, I don't remember. But what I can say for sure is that most of these changes would most probably affect major version of node-opencl. In any case I'm open to help with transition (full or parts) but it'll definitely take some time to happen... |
Gotcha, thanks! We're seeing some fires on the new AWS G4s, which is ~4x cheaper than any of the others, so that shot up in priority. After we figure that out (1w?), will try this & report back! |
Hi @lu4 , just got commit access & merged the non-TS branch, and happy to test & land this one when you think it's ready. |
RE:Breaking changes, esp. for increased conformance & coverage , sounds worthwhile, we can just do a major version bump & call out in a changelog. |
@lmeyerov sounds cool, I'm experimenting with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through individual files, will post full msg on main thread
@@ -0,0 +1,55 @@ | |||
{ | |||
// Use IntelliSense to learn about possible attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is default Visual Studio Code launch.json
config file, I think it is reasonable to remove it
|
||
I've taken the initiative to renovate the existing code for my own purposes and now I'm sharing the result in hope that it will be useful for anyone else who is lacking typescript support with `node-opencl`. | ||
|
||
This project contains full typings coverage of OpenCL 1.0-2.0 (and OpenCL 2.1, 2.2 ready to be implemented) specification (based on Khronos specification) with node-opencl specifics taken into account. The package also contains couple of minor bugfixes suggested by community PRs in original repo and couple of mine aesthetic interface changes / additions and changes related to management of deprecated OpenCL apis (basically I enabled the use of deprecated APIs if they were still supported by OpenCL implementation). Which I think may block mikeseven from merging current changes into `node-opencl`. Nevertheless in order to not partition the community with redundant library versions I'm open to kill this repo in event of merge with `node-opencl`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the TS-specific docs to a subsection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can stick to original readme, or have new one created, no need for message above
@@ -1,11 +1,13 @@ | |||
{ | |||
"name": "node-opencl", | |||
"version": "0.4.5", | |||
"name": "node-opencl-ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this as part of core node-opencl, unless a distinct package is a convention in ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will rename this to original package name
], | ||
"license": "BSD-3-Clause", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mikeseven/node-opencl.git" | ||
"url": "https://github.com/lu4/node-opencl-ts.git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/lu4/mikeseven...
}, | ||
"bugs": { | ||
"url": "https://github.com/mikeseven/node-opencl/issues" | ||
"url": "https://github.com/lu4/node-opencl-ts/issues" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
testString(device, "DEVICE_BUILT_IN_KERNELS"); | ||
testString(device, "DEVICE_SPIR_VERSIONS"); | ||
// testString(device, "DEVICE_BUILT_IN_KERNELS"); | ||
// testString(device, "DEVICE_SPIR_VERSIONS"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not skip tests... better to guard tests by hw build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rethink this
@@ -27,7 +27,7 @@ describe("Event", function() { | |||
|
|||
describe("#getEventInfo",function(){ | |||
function testNumber(info,name,expected) { | |||
it("should return the good value for " + name, function () { | |||
skip().vendor("nVidia").it("should return the good value for " + name, function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more skipped tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see more need of incremental migration to TypeScript support.
@@ -138,11 +140,11 @@ describe("Kernel", function () { | |||
U.withProgram(ctx, squareKern, function (prg) { | |||
var k = cl.createKernel(prg, "square"); | |||
|
|||
if (cl.VERSION_1_2) { | |||
U.bind(cl.setKernelArg, k, 0, [5, 10, 15]) | |||
if (cl.v12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more v12 refactors, not sure why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can return back the naming but except for naming itself there are changes related to contents of namespaces, node-opencl
does not provide deprecated APIs on javascript side, it is literally excluded during C++ compile time, I think this is wrong thing to do, if API is there it should be available. As for reasons to change naming is that I find 'v12' more convenient to write, no need to shout VERSION (press shift) (press minus) 1 (press shift) (press minus) 2
} | ||
assert(cl.setKernelArg(k, 2, 5, "uint") == cl.SUCCESS); | ||
assert(cl.setKernelArg(k, 2, "uint", 5) == cl.SUCCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like kernel arg order changed, call out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
@@ -402,47 +404,47 @@ describe("MemObj", function() { | |||
}); | |||
}); | |||
|
|||
it("should get supported image formats", function () { | |||
skip().vendor('nVidia').it("should get supported image formats", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why skip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't have an answer now
Wow, went through all core files and most of tests, this is great! AFAICT, this: -- Adds TS 🚀🚀🚀 My thinking to get landed: So maybe the flow is: Sounds reasonable / ideas? Also, we can probably donate an Azure Pipelines CI testing across AWS intel/nvidia, if helpful |
Cool! Yeah, I'm cool with most things that eliminate code and improve maintainability. Some of those look like quite risky dependencies that'll bite us in 6mo so rather not take on the likely coming tech debt, but beyond that, am supportive. |
Ok, I'm back, will review and respond to your comments, will create a checklist and gradually will fix them... |
Ok, I've reviewed all your comments, I see that it might be too hard to try to move the new thing on top of old thing, there are too many layers of changes. Let's do it this way, I see that it's possible to introduce TypeScript bindings into existing project without touching the C++ side. I'll do this in a separate PR, and as of that we can start moving towards C++ changes (if necessary) I'm saying "if necessary" because I'd rewrite the whole thing from scratch, I don't like most of the things I see, but unfortunately I don't have time for such adventure. So let's go forward with this step by step... What are your thoughts on this? |
Yes, splitting it up would make this a lot more approachable! Maybe something like:
2a. C++ changes (nan, ...) as a diff PR, ideally also as a minor semvar that conforms to (1)'s TS 2b. New abstractions (eg., async/await) as a major semvar, and maybe have live as an @next for awhile => "node-opencl 2.0" EDIT: Should I respond to the comments, or do anything else to help for next steps? |
This PR is a major rewrite for the library, it introduces TypeScript support for node-opencl. Suggested changes are not backward compatible, there are changes in package.json, and changes in both C++ backend interface and NodeJS frontend interface, also MR contains couple of bugfixes, also there are changes in ... ... ... everywhere. I think this PR requires broader attention and some time to sync with existing code base. Or at least something to start with...
Hope to hear out your comments!
Thank you in advance!