bugGNU Octave - Bugs: bug #64882, Slow to pass arrays out of...

 
 

bug #64882: Slow to pass arrays out of mexFunction

Submitter:  None
Submitted:  Sat 11 Nov 2023 01:59:17 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Need Info Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 8.3.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 Nov 2023 09:21:17 PM UTC, comment #5: 

Correction, g++-9. That solved it!

octave:4> A=rand(20000);
octave:5> tic;B=TestFunc(A);toc
Entered      : Elapsed time is 0.00041604 seconds.
Parsed args  : Elapsed time is 0.000488043 seconds.
Created array: Elapsed time is 1.83954 seconds.
Elapsed time is 1.83962 seconds.

Well, apart from the 1.8 seconds to calloc a 3Gb array... ;)

Anonymous
Mon 13 Nov 2023 08:55:23 PM UTC, comment #4: 

Nice catch. I did a quick scan and saw this:

configure:14917: checking whether std::pmr::polymorphic_allocator is available
configure:14968: g++ -std=gnu++17 -c -g -O2  conftest.cpp >&5
conftest.cpp:71:16: fatal error: memory_resource: No such file or directory
       #include <memory_resource>
                ^~~~~~~~~~~~~~~~~
compilation terminated.
configure:14968: $? = 1
configure: failed program was:
| /* confdefs.h */

Trying again with g++-8.

Anonymous
Mon 13 Nov 2023 07:48:23 AM UTC, comment #3: 

Could you please upload the config.log file? (To make sure it actually used std::pmr::polymorphic_allocator. And potentially find why it might not have used it.)

Markus Mützel <mmuetzel>
Group administrator
Sun 12 Nov 2023 07:55:20 PM UTC, comment #2: 

Thanks for the suggestion. Tried it - no difference.

octave:7> A=rand(20000);
octave:8> tic;B=TestFunc(A);toc
Entered      : Elapsed time is 0.000444889 seconds.
Parsed args  : Elapsed time is 0.000519991 seconds.
Created array: Elapsed time is 1.85883 seconds.
Elapsed time is 4.4488 seconds.

Anonymous
Sun 12 Nov 2023 09:42:07 AM UTC, comment #1: 

Could you try to configure Octave with `--enable-std-pmr-polymorphic-allocator`? Does that make a difference? (You'll need a compiler that supports C++17 to be able to build with that configuration.)

Markus Mützel <mmuetzel>
Group administrator
Sat 11 Nov 2023 01:59:17 PM UTC, original submission:  

Passing a large array out of a mexFunction seems to take an extremely long time. I couldn't get very far figuring out what is happening but it may be related to "mutable" and making deep copies of mxArray types into native Octave types. It's strange because passing large (Octave type) array into a mexFunction doesn't incur the same penalty.

I wonder if this could be improved, even just for a few standard types (numeric arrays).

Attached is a small example which receives a large array and returns a large array of the same size.

>> mex TestFunc.cpp
>> A=rand(20000);
>> tic;B=TestFunc(A);toc


In Octave:
Entered      : Elapsed time is 0.000358105 seconds.
Parsed args  : Elapsed time is 0.000403166 seconds.
Created array: Elapsed time is 1.82221 seconds.
Elapsed time is 4.34962 seconds.

In Matlab:
Entered      : Elapsed time is 0.002034 seconds.
Parsed args  : Elapsed time is 0.002162 seconds.
Created array: Elapsed time is 0.002450 seconds.
Elapsed time is 0.002602 seconds.


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55318:  TestFunc.cpp added by None (651B - text/x-c++src)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-11-13 mmuetzel StatusNone Need Info
    2023-11-11 None Attached File- Added TestFunc.cpp, #55318

    Back to the top

    Powered by Savane 3.12