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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:22:08+00:00 2026-05-28T01:22:08+00:00

I am a recreational pythonista who just got into pyCUDA. I am trying to

  • 0

I am a recreational pythonista who just got into pyCUDA. I am trying to figure out how to implement a linear interpolation (lerp) using pyCUDA. The CUDA CG function is: http://http.developer.nvidia.com/Cg/lerp.html

My ultimate goal is a bilinear interpolation in pycuda from a set of weighted random points. I’ve never programmed C, or CUDA for that matter, and am learning as I go.

This is how far I’ve gotten:

import pycuda.autoinit
import pycuda.driver as drv
import pycuda.compiler as comp

lerpFunction = """__global__ float lerp(float a, float b, float w)
{
    return a + w*(b-a);
}"""

mod = comp.SourceModule(lerpFunction) # This returns an error telling me a global must return a void. :(

Any help on this would be fantastic!

  • 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-05-28T01:22:09+00:00Added an answer on May 28, 2026 at 1:22 am

    The error message is pretty explicit – CUDA kernels cannot return values, they must be declared void, and modifiable arguments passed as pointers. It would make more sense for your lerp implementation to be declared as a device function like this:

    __device__ float lerp(float a, float b, float w)
    {
        return a + w*(b-a);
    }
    

    and then called from inside a kernel for each value that requires interpolation. Your lerp function lacks a lot of “infrastructure” to be a useful CUDA kernel.


    EDIT: A really basic kernel along the same lines might look something like this:

    __global__ void lerp_kernel(const float *a, const float *b, const float w, float *y)
    {
        int tid = threadIdx.x + blockIdx.x*blockDim.x; // unique thread number in the grid
        y[tid] = a[tid] + w*(b[tid]-a[tid]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to make a recreation of MSWord using WPF RichTextBox and Toolbar, so
A friend (fellow low skill level recreational python scripter) asked me to look over
I have been doing a little recreational holiday computing. My mini-project was a simulation
The recommended practice of using --reintegrate is generally understood by me. However, the practice
I have a zipcode field in a database that I just took over. Previously,
I am exporting an excel workbook into xml spreadsheet. The excel has lets say
I was trying to find something original and fun to do with artificial neural
I am working on a recreation of a search control using the MVVM pattern.
I understand that you generally serialize objects for data persistence using the NSCoder protocol
I am defining some active records with acronyms. RvPark (Recreational Vehicle Park). When 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.