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 7951981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:43:28+00:00 2026-06-04T02:43:28+00:00

I do some calculations in my code on a float* memory block. Since I

  • 0

I do some calculations in my code on a float* memory block. Since I am working on an image, I will have to do this with width * height points, and 180 rotations. I am starting 180 threads (1 per degree rotation), since this is the only parallelizable procedure in the code.
I rotate the images, and get for every rotation, for every point a resulting float value.
I have another float* block which stores the current maximum value at each point.

if(resultMap[i] < convrst)
{
    resultMap[i] = convrst;
    rMap[i] = (unsigned char)r0;
    oMap[i] = (unsigned char)index;
}

with resultMap storing the current highest value. convrst is the result of the convolution, and if the current result is higher than the ones before, it will save the value, plus the radius (r0) and rotation (index) at that point. r0 is originally an int, as well as index.
i is an counter going from 0 to imgsize-1

Without the assignments in the { } part, the whole code will finish within like 2s, with the assignments it takes like 50s (and this is not taking into account that in that code I left out the locks to avoid synchronization problems).

Why is that code so slow, and what can I do to make it finish faster?

  • 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-04T02:43:29+00:00Added an answer on June 4, 2026 at 2:43 am

    The reason for the large slowdown when you include writes in your kernel is the same as in this question (although it is about OpenCL the principle is the same). The NVIDIA compiler is extremely aggressive at optimising away “dead” code, that is code which does not contribute to a shared memory or global memory write. So I would guess that when you don’t include a write to global memory, as shown in your question, the compiler is just optimising large amounts of the kernel away, greatly reducing the execution time.

    So, as in the other question I linked to, the real question should be why your kernel taking 50 seconds to finish. That will require more information about the code and the execution parameters you are calling it with, but if, as you wrote, you are running only 180 threads, that is the likely culprit. The GPU needs a lot more parallelism than that to achieve anything like peak performance.

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

Sidebar

Related Questions

let's say I have a class that does some calculations. This set of calculations
I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write
I have C code doing some calculations (irrelevant to my question, I believe ).
I have some very heavy code to develop and want to make some calculations
I need to write application in .NET which will be make some calculations on
So, I am having trouble with some code. I want this function to take
I've got some image processing code in C++ which calculates gradients and finds straight
I'm working on an old-school image warp filter. Essentially, I have a 2D array
I have 2 tables that I'm trying to use to perform some calculations. My
I have a class that encapsulates some arithmetic, let's say fixed point calculations. I

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.