octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63962] perms - Performance - Usage of native


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #63962] perms - Performance - Usage of native C++ algorithm helpful
Date: Mon, 27 Mar 2023 18:33:22 -0400 (EDT)

Follow-up Comment #15, bug #63962 (project octave):

@Hendrik: I've attached a patch version of your function. The changes I made
were these:

1. Copy the new file perms.cc to libinterp/corefcn
2. hg add libinterp/corefcn/permc.cc (add to repository)
3. Add perms.cc to libinterp/corefcn/module.mk (add to build system)
4. Delete scripts/specfun/perms.m
5. hg forget scripts/specfun/perms.m  (remove from repository) and .
6. Remove perms.m from scripts/specfun/module.mk  (remove from build system)
7. Edit perms.cc and change DLD to DEFUN. Use one of the DEFUN functions in
data.cc as an example.
8. Copy include files at the top, using __isprimelarge__.cc as an example.
9. Build and fix compilation errors: remove oct.h, and fix the "template
required" errors for all the "const Array foo = ...".
10. Add a print_usage at the start of the function.

Now it builds and passes "make check". You can compare the DLD format to the
DEFUN format.

It still needs formatting work, which I will leave to you. The Octave code
guidelines are here, for your reference:
https://wiki.octave.org/C%2B%2B_style_guide 

For benchmarking, this code:

tic; for n = 1:11, perms(1:n); end; toc

takes 6.5 seconds on the unpatched version and 1.2 seconds on the patched
version, while this code:

tic; for n = 1:15, v = round((1:n) / sqrt(n)); perms(v, "unique"); end; toc

takes 22.4 seconds on unpatched and 2.05 seconds on patched. Well done!


(file #54535)

    _______________________________________________________

Additional Item Attachment:

File name: perms.patch                    Size:19 KB
    <https://file.savannah.gnu.org/file/perms.patch?file_id=54535>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63962>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]