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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:55:55+00:00 2026-05-22T21:55:55+00:00

I have two cuda files say A and B. I need to call a

  • 0

I have two cuda files say A and B.
I need to call a function from A to B like..

__device__ int add(int a, int b) //this is a function in A
{
   return a+b;
}



__device__ void fun1(int a, int b) //this is a function in B
{
    int c = A.add(a,b);
}

How can I do this??

Can I use static keyword? Please give me an example..

  • 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-22T21:55:55+00:00Added an answer on May 22, 2026 at 9:55 pm

    The short answer is that you can’t. CUDA only supports internal linkage, thus everything needed to compile a kernel must be defined within the same translation unit.

    What you might be able to do is put the functions into a header file like this:

    // Both functions in func.cuh
    #pragma once
    __device__ inline int add(int a, int b) 
    {
       return a+b;
    }
    
    __device__ inline void fun1(int a, int b)
    {
        int c = add(a,b);
    }
    

    and include that header file into each .cu file you need to use the functions. The CUDA built chain seems to honour the inline keyword and that sort of declaration won’t generate duplicate symbols on any of the CUDA platforms I use (which doesn’t include Windows). I am not sure whether it is intended to work or not, so cavaet emptor.

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

Sidebar

Related Questions

I have two identical tables and need to copy rows from table to another.
I have two classes Order and Items I want a method like this class
Have two folders with approx. 150 java property files. In a shell script, how
Say I have a vector of keys thrust::device_vector<int> keys(10); keys[0] = 51; // ----->
I have this two vector<double> 's mass and velocity both of the same size
I have a short piece of code like this: typedef struct { double sX;
I have two questions related to CUDA 4.0 Peer access: Is there any way
I have to write in a PyCUDA function that gets two matrices Nx3 and
I am trying separate a CUDA program into two separate .cu files in effort
Have two files with struct definitions. Header: typedef struct _InputData InputData; extern InputData input_data;

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.