[Top][All Lists]

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

[Octave-bug-tracker] [bug #52756] implement xor as C++ function

From: Rik
Subject: [Octave-bug-tracker] [bug #52756] implement xor as C++ function
Date: Thu, 28 Dec 2017 16:49:58 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0


                 Summary: implement xor as C++ function
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Thu 28 Dec 2017 01:49:57 PM PST
                Category: Octave Function
                Severity: 1 - Wish
                Priority: 5 - Normal
              Item Group: Performance
                  Status: Confirmed
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any



The xor function, as opposed to the other logical functions such as and() and
or(), is implemented as an m-file.  That's fine, but it is approximately 5X
slower than a C++ implementation.  In addition, most modern CPUs have a
hardware implementation of xor which it would be nice to piggyback on.

For benchmarking I used the following script

N = 1e4;
N2 = 1e3;

x = zeros (N2,1);
y = ones (N2,1);

bm = zeros (N, 1);
for i = 1:N
  #z = xor (x, y);
  #z = or (x, y);
  bm(i) = toc;

sum (bm)

Times for xor() were about 0.80 seconds while times for the or() function were
just 0.16 seconds (5X).  As part of this, xor would drop support for multiple
inputs beyond two, but that is okay as Matlab and all of the other logical
functions in Octave are limited to two inputs.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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