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

  • Home
  • SEARCH
  • 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 8435511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:56:07+00:00 2026-06-10T06:56:07+00:00

I’d like to find non-zero elements of a matrix as fast as possible. Having

  • 0

I’d like to find non-zero elements of a matrix as fast as possible. Having CUDA \ Jacket in mind, I’ve learned that this is much slower than the “regular” CPU version of Matlab‘s find, probably due to memory allocation issues, since the size of the output is not known prior to the find function. However, using bwlabel and regionprops (both supported in Jacket) does effectively yield info regarding the non-zero elements, and much faster than Matlab‘s built in Image Processing Toolbox functions. Is there a way to harness this to get the non-zero elements? Is there instead a way to do some processing on each of the labeled objects that are found using bwlabel?

  • 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-10T06:56:08+00:00Added an answer on June 10, 2026 at 6:56 am

    In my experience, the FIND implementation supported by Jacket is very fast, at least for matrices larger than 300×300 or so. I tested this on my laptop and share the results in what follows. My HW specs are:

    >> ginfo
    Jacket v2.2 (build 77be88c) by AccelerEyes (64-bit Windows)
    License: Standalone (C:\Program Files\AccelerEyes\Jacket\2.2\engine\jlicense.dat)
    Addons: MGL16, JMC, SDK, DLA, SLA
    CUDA toolkit 4.2, driver 4.2 (296.10)
    GPU1 GeForce GT 540M, 2048 MB, Compute 2.1 (single,double)
    Display Device: GPU1 GeForce GT 540M
    Memory Usage: 1697 MB free (2048 MB total)
    

    CPU is Intel Core i7-2630QM.

    I get that Jacket hits ~3X speedups on the FIND function over the CPU. Here is the benchmark code I used:

    % time Jacket vs CPU
    for n = 5:12;
        x(n) = 2^n;
        Ac = single(rand(x(n)));
        Ag = gsingle(Ac);
        t_cpu(n) = timeit(@() find(Ac > 0.5));
        t_gpu(n) = timeit(@() find(Ag > 0.5));
    end
    
    % plot results
    plot(x, t_cpu ./ t_gpu);
    xlabel('Matrix Edge Size', 'FontSize', 14);
    ylabel('Jacket (GPU) Speedup over CPU', 'FontSize', 14);
    

    Here are the results of running this code:

    Jacket (GPU) Speedup over CPU

    I’m sure the BWLABEL and REGIONPROPS functions supported by Jacket are also very fast, but you might be able to get by with FIND itself given the benchmarks above.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

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.