Skip to content

Some minor fixes and extensions to CLU#1

Open
arthurp wants to merge 7 commits intoOblomov:masterfrom
arthurp:master
Open

Some minor fixes and extensions to CLU#1
arthurp wants to merge 7 commits intoOblomov:masterfrom
arthurp:master

Conversation

@arthurp
Copy link
Copy Markdown
Contributor

@arthurp arthurp commented Jun 7, 2012

I have fixed a few bugs and added an install target to the make file to make this nice little package easier for me to use. I am also working on some extensions to it that I will push in your direction soon.

Tell me if there are any specific requirements for patches. For instance what platforms do they need to work on?

Thanks.
-Arthur

@arthurp
Copy link
Copy Markdown
Contributor Author

arthurp commented Jun 8, 2012

The last commit adds several new functions. I believe they are all worth including. But of course that is up to you. They are documented in the include file.

cluGetContextDefaultDevice
Get the first device of a context. Useful when a function is passed a context but needs a device. Obviously in cases where there is more than one device this would not be useful but the norm is a single device I believe.

cluCreateContextByType
Allows the context of a specific device type to be created without knowing anything about the platforms on the system in the user code.

cluHostMallocPageAligned
Allocating page aligned host memory makes mem mapping and other things much faster. So a function to do it easily is useful.

cluBuildProgramSimple
This simply avoid the need to remember what the other parameters to clBuildProgram need to be to get defaults. Which is nice for simple programs.

cluRoundUp
Rounding up to round number is important for setting global and local sizes so this is a common need in an OpenCL program. I stool the implementation from your other OpenCL github repo in fact.

Tell me what you think. And if you want me to split them into separate commits I can.

@Oblomov
Copy link
Copy Markdown
Owner

Oblomov commented Jun 9, 2012

Thanks for the patches. For the moment I'm only interested in supporting POSIX-like systems (mostly Linux, but patches to support *BSD systems are equally welcome). I've commented on a few patches, and regarding the last one yes, I'd prefer if you split it: some of it can be trivially merged, other requires some more attention. Two notes you can keep in mind when splitting it:

  • cluRoundUp should use size_t instead of unsigned long
  • I like the cluHostMallocPageAligned() but I think it should use a different design. I'm thinking along something like cluMallocHost with flags, where one flag is used to specify that it should be page-aligned. Needs some thought.

@arthurp
Copy link
Copy Markdown
Contributor Author

arthurp commented Jun 9, 2012

OK I reworked the set of commits. I think this addressed all of your issues with them. cluHostMalloc... is not in a branch. I'll do a first version of the cluMallocHost you talked about (with just one flag PAGE_ALIGNED for the moment) and then merge and push that branch. Tell me if anything else needs to be fixed.

I had a thought about the cluGetPlatformByName bug (not reflected in these changes). Maybe just using clGetPlatformInfo directly would be appropriate. Because cluGetPlatformByName will probably only be called once for one platform so the only wasted call in that case would be a single call to clGetPlatformInfo. On the other hard the current method might be just fine. The extra loads will not be an issue because they will only happen once during initialization. But that's up to you.

PS: I'm fairly new to git (I'm usually a mercurial guy and even then I'm not that skilled) so I apologize for messing with my commit history. I didn't know any other way to make the changes needed.

@arthurp
Copy link
Copy Markdown
Contributor Author

arthurp commented Jun 9, 2012

Oh and I was thinking about writing a function (or extending the functionality of cluBuildProgramSImple) to allow it to return compiler errors in the case of a build failure. Maybe something as simple as a size_t/char* argument pair that is loaded with build log whether is succeeds or fails. This would avoid the need for people to call clGetProgramInfo separately. Which would help approach the ease of use of CUDA. And people can always use clBuildProgram instead if they like.

What do you think?

@Oblomov
Copy link
Copy Markdown
Owner

Oblomov commented Jun 16, 2012

I've merged some of the commits (and fixed a few whitespace problems when doing it). Here's what I haven't merged yet, and why:

  • cluCreateContextByType: I haven't merged this because I'm not sure about the name; calling it ...FromType would make it more consistent with the OpenCL API, but By sounds more grammatically correct; shouldn't it be Of though, then? There are also a few notes I'm adding to the code itself.
  • cluGetContextDefaultDevice: I'm not 100% convinced of the semantics of this. On the one hand, I understand the need to just get the (typically only) device of a context, but I'm also wondering if it wouldn't be better to get all the devices anyway, i.e. rather have something like cluGetContextDevices with a semantics similar to that of cluGetDevices; however, this obviously has the annoying side-effect of a more complex memory management. So I'm still thinking about it.
  • cluBuildProgramSimple: this is probably a little bit too simplified: I would still allow passing command-line options. But this can be implement with some cluSetBuildOptions. Also, I think the name of the function should just be cluBuildProgram.

Regarding cluBuildProgram returning the log, I would still prefer to have it as a separate command, rather, since you typically only want the log if there is some problem. A cluGetBuildLog would be nice though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants