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

The Archive Base Latest Questions

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

Hey there, I have a mex file which I want to parallelize with the

  • 0

Hey there,
I have a mex file which I want to parallelize with the help of CUDA. The current functionality is: I pass a function handle and a huge number of ‘points’ to the mex file and it evaluates the function on each of the points in sequential mode (on the CPU). It therefor uses something like:

mxArray* y;
const mxArray *e[2] = {functionHandle, point};
mexCallMATLAB(1, &y, 2, (mxArray **)e, "feval");

to evaluate the function Handle on the point using the matlab-function feval. Now I wonder what happens when I try to parallelize the calculations via CUDA: Will this work correctly? Because if the evaluation with mexCallMATLAB is done on the CPU, there won’t be any benefit using CUDA. But how to do it than? I can’t imagine any way to evaluate a function handle on a certain point in C directly without using the matlab-function feval…

Thanks so far!
You’ll help me a lot!

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

    No, mexCallMATLAB will not be callable from the GPU. In general, host-side calls cannot be made from within the body of a CUDA Kernel.

    You may find that if you have access to Parallel Computing Toolbox, you can use GPUArrays with arrayfun. For example, if the function you wish to evaluate across many points looks like this:

    function y = myFcn( x )
    y = 1;
    for ii = 1:10
      y = sin(x * y);
    end
    

    Then you could call this on the GPU like so:

    gx = gpuArray( rand(1000) );
    gy = arrayfun( @myFcn, gx );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there, assuming I have a compiled mex file with the name 'myMx', is
Hey there I have this function: void vdCleanTheArray(int (*Gen_Clean)[25]) { } I wanted to
hey there i am having problem i have List<List<memoryCard>> that i want to show
Hey there, I'm trying to make a site which have following: News, Products, About
Hey there I have 2 tables with each multiple columns and i want to
Hey there, i have a table with a field called file full of binary
Hey there. Basically, I have a batch-file, that goes through all model and texture
Hey there, I have a big code file currently in C++ with many functions
Hey there, assuming I have the following code in a mex routine: mxArray *newPoint
Hey there, I have a small problem with compiling and linking with the command

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.