Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:08:04+00:00 2026-06-02T05:08:04+00:00

I’ve been experimenting with CUDA kernels for days to perform a fast 2D convolution

  • 0

I’ve been experimenting with CUDA kernels for days to perform a fast 2D convolution between a 500×500 image (but I could also vary the dimensions) and a very small 2D kernel (a laplacian 2d kernel, so it’s a 3×3 kernel.. too small to take a huge advantage with all the cuda threads).

I created a CPU classic implementation (two for loops, as easy as you would think) and then I started creating CUDA kernels.

After a few disappointing attempts to perform a faster convolution I ended up with this code:
http://www.evl.uic.edu/sjames/cs525/final.html (see the Shared Memory section), it basically lets a 16×16 threads block load all the convolution data he needs in the shared memory and then performs the convolution.

Nothing, the CPU is still a lot faster. I didn’t try the FFT approach because the CUDA SDK states that it is efficient with large kernel sizes.

Whether or not you read everything I wrote, my question is:

how can I perform a fast 2D convolution between a relatively large image and a very small kernel (3×3) with CUDA?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:08:05+00:00Added an answer on June 2, 2026 at 5:08 am

    You are right in that 3×3 kernel is not suitable for FFT based approach. The best way to deal with this would be to push the kernel into constant memory (or if you are using a fermi+ card, this should not matter too much).

    Since you know kernel size, the fastest way to do this would be to read chunks of the input image / signal into shared memory and perform an unrolled multiply and add operation.

    —

    If you are willing to use libraries to perform this operation ArrayFire and OpenCV
    have highly optimized Convolution routines that can save you a lot of development time.

    I am not too familiar with OpenCV, but in ArrayFire you can do something like the following.

    array kernel = array(3, 3, h_kernel, afHost); // Transfer the kernel to gpu
    array image  = array(w, h, h_image , afHost); // Transfer the image  to gpu
    array result = convolve2(image, kernel);       // Performs 2D convolution
    

    EDIT

    The added benefit of using ArrayFire is its batched operation allows you to perform convolution in parallel. You can read about how convolvutions support batch operations over here

    For example if you had 10 images that you want to convolve using the same kernel, you could do somehting like the following:

    array kernel = array(3, 3, h_kernel, afHost);     // Transfer the kernel to gpu
    array images = array(w, h, 10, h_images, afHost); // Transfer the images to gpu
    array res    = convolve2(images, kernel); // Perform all operations simultaneously
    

    —

    Full Disclosure: I work at AccelerEyes and actively work on ArrayFire.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.