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

add image_load_from_memory helper #24

Closed
wants to merge 1 commit into from

Conversation

XuhuiSun95
Copy link

Hello,

I am recently working on GPU jpeg encoding and this library offered me some great tools to accomplish my goal.
With some sort of digging on the source code, I realized there is no helper method that load image already in the memory. I would like to contribute my code to help encode raw data that already in the memory.
Notes that my method modified based on gpu_image_load_from_file, however, some of the parameters are not working exactly the same as load_from_file. But this should provide a similar way to load data into CUDA host buffer. I have tested this method on my own code and it works as I desired.
Please let me know if there is anything need to improve on this pull request, and I would like to hear your feedback.

Best,
Xuhui

@MartinPulec
Copy link
Collaborator

Hi Xuhui,

I am not sure what is the advantage of that function. I mean, why just don't call gpujpeg_encoder_input_set_image with the buffer? Actually I think that the only advantage is that after the gpujpeg_encoder_input_set_image call, the input buffer can be released. Is this the aim?

However, I don't think that for effective usage of the library, cudaMallocHost should not be called for every image, because the function is quite costy. If you need to make a copies of the buffers, I'd allocate the pinned-buffer memory (allocated with cudaMallocHost) once and then reuse that repeatedly. If the use is just one-shot, it shall be sufficient to use gpujpeg_image_load_from_memory directly (it does the same, copies the buffer to a pinned memory, see here).

Regards,
Martin

@XuhuiSun95
Copy link
Author

Hi Martin,

I think you are right. Because I am only starting to using CUDA, I am not so familiar with all the differences between cudaMalloc and when should I use which. Thanks for bringing up some reference and I will close the request.

Best,
Xuhui

@XuhuiSun95 XuhuiSun95 closed this May 21, 2019
@MartinPulec
Copy link
Collaborator

Hi Xuhul,

actually you correctly pointed out that it is not quite clear in the GPUJPEG API. The "official" functions are those gpujpeg_encoder_input_*. The load_from_file function is rather an utility function used by the command-line application.

Martin

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.

None yet

2 participants