Code Monkey home page Code Monkey logo

stingergraphs.jl's People

Contributors

fredrikekre avatar jpfairbanks avatar rohitvarkey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ehein6 tkelman

stingergraphs.jl's Issues

Trying to remove a loop edge makes stinger go into an infinite loop

using StingerWrapper
s = Stinger()
insert_edge!(s, 0, 1, 1, 0, 0)
remove_edge!(s, 0, 1, 1) #Goes into infinite loop

The C definition of remove_edge! does have a note specifying how this function should not be called concurrently with the same source.

@jpfairbanks Does this case come under that condition? I guess we should add a check for this at the wrapper side (in remove_edge) in any case.

If we are not able to allow for deletion of loop edges, should we allow such an edge to be inserted in insert_edge! in the first place?

edge weight inserted in one direction only

I noticed that when an edge is inserted, somehow the edge weight is only returned in one direction but not the other. For example:

g1 = Stinger(StingerGraphs.StingerConfig(100, 1004, 1, 1, 110^6, 0, 0, 0))
insert_edge!(g1, 0, 1, 2, 3, 0)

foralledges(g1, 1) do edge, src, etype
direction, neighbor = edgeparse(edge)
println(direction, " ", neighbor," ", edge.weight)
end

produces "2 2 3" as expected, but

foralledges(g1, 2) do edge, src, etype
direction, neighbor = edgeparse(edge)
println(direction, " ", neighbor," ", edge.weight)
end

produces "1 1 0", with weight being 0.

edgeweight function much slower than edgeparse

Not sure this is an issue, but I noticed that retrieving edges weights using the edgeweight(g, src, dest, etype) function is significantly slower (~20 times) than just parsing the edge (i.e. edgeparse(edge)). Perhaps I am not retrieving the edge weight the right way? I am doing this on directed and weighted graphs with 1-10M edges. Thank you!

atomics

I think the

function atomic_cas!(x::Array{T}, i::Int, cmp::T, new::T)
    ptr = pointer(x) + i*sizof(T)
    llvmcall($"""
                         %rs = cmpxchg $lt* %0, $lt %1, $lt %2 acq_rel acquire
                         %rv = extractvalue { $lt, i1 } %rs, 0
                         ret $lt %rv
                         """, $typ, Tuple{Ptr{$typ},$typ,$typ},
                         ptr, cmp, new)
end

stuff would be a really great contribution to base julia.

Neighborhood iteration on julia side

It appears that the biggest performance hit we take in julia is using the gather_successors functiohn https://github.com/stingergraph/stinger/blob/dev/lib/stinger_core/src/stinger.c#L1832

If we could do the iteration over the edge blocks on the julia side, we could avoid a huge overhead.
This is the key C macro that this code uses: https://github.com/stingergraph/stinger/blob/dev/lib/stinger_core/inc/stinger_traversal.h#L123.

If the STINGER_FORALL_EDGES_OF_VTX macros were made into julia iterators, we could avoid a lot of overhead. The most direct port is a julia macro with the following usage

@forall_edges_of_vtx begin
    n = STINGER_EDGE_DEST
    w = STINGER_EDGE_WEIGHT
    tf = STINGER_EDGE_TIME_FIRST
    tr = STINGER_EDGE_TIME_RECENT
    t = STINGER_EDGE_TYPE
    if n >= 0 
      size_t where = stinger_size_fetch_add (&kout, 1)
      if where < max_outlen
        out[where] = n
        if(weight) weight[where] = w
        if(timefirst) timefirst[where] = tf
        if(timerecent) timerecent[where] = tr
        if(type) type[where] = t
      end
    end
end

Where the variables are defined in the macro like

/* Use these to access the current edge inside the above macros */
#define STINGER_EDGE_SOURCE source__
#define STINGER_EDGE_TYPE type__
#define STINGER_EDGE_DEST ((current_edge__->neighbor)&(~STINGER_EDGE_DIRECTION_MASK))
#define STINGER_EDGE_DIRECTION ((current_edge__->neighbor)&(STINGER_EDGE_DIRECTION_MASK))
#define STINGER_EDGE_WEIGHT current_edge__->weight
#define STINGER_EDGE_TIME_FIRST current_edge__->timeFirst
#define STINGER_EDGE_TIME_RECENT current_edge__->timeRecent
#define STINGER_IS_OUT_EDGE ((current_edge__->neighbor)&(STINGER_EDGE_DIRECTION_OUT))
#define STINGER_IS_IN_EDGE ((current_edge__->neighbor)&(STINGER_EDGE_DIRECTION_IN))
#define STINGER_GENERIC_FORALL_EDGES_OF_VTX_BEGIN(STINGER_,VTX_,EDGE_FILTER_,EB_FILTER_,PARALLEL_)\
  do {                                                                                                    \
    MAP_STING(STINGER_);                                                                                  \
    struct stinger_eb * ebpool_priv = ebpool->ebpool;                                                     \
    struct stinger_eb *  current_eb__ = ebpool_priv + stinger_vertex_edges_get(vertices, VTX_);           \
    while(current_eb__ != ebpool_priv) {                                                                  \
      int64_t source__ = current_eb__->vertexID;                                                          \
      int64_t type__ = current_eb__->etype;                                                               \
      EB_FILTER_ {                                                                                        \
        PARALLEL_                                                                                         \
        for(uint64_t i__ = 0; i__ < stinger_eb_high(current_eb__); i__++) {                               \
          if(!stinger_eb_is_blank(current_eb__, i__)) {                                                   \
            struct stinger_edge * current_edge__ = current_eb__->edges + i__;                             \
            EDGE_FILTER_ {

#define STINGER_GENERIC_FORALL_EDGES_OF_VTX_END()         \
            } /* end EDGE_FILTER_ */                      \
          } /* end if eb blank */                         \
        } /* end for edges in eb */                       \
      } /* end EB_FILTER_ */                              \
      current_eb__ = ebpool_priv + (current_eb__->next);  \
    } /* end while not last edge */                       \
  } while (0)

This could also get turned into a function that satisfied the do notation interface.

function forall_neighbors(func::Function, s::Stinger, v::Int)
   for u in edgeblocks(s, v)
       f(s, v, u)
   end
end

so that you would use it like

   forall_neighbors(s, v) do s, v, u
       #function body
   end

I guess this requires edgeblocks as an iterator http://docs.julialang.org/en/release-0.5/manual/interfaces/.

I think either way will reduce the overhead and get nearly equal performance.

Info about upcoming removal of packages in the General registry

As described in https://discourse.julialang.org/t/ann-plans-for-removing-packages-that-do-not-yet-support-1-0-from-the-general-registry/ we are planning on removing packages that do not support 1.0 from the General registry. This package has been detected to not support 1.0 and is thus slated to be removed. The removal of packages from the registry will happen approximately a month after this issue is open.

To transition to the new Pkg system using Project.toml, see https://github.com/JuliaRegistries/Registrator.jl#transitioning-from-require-to-projecttoml.
To then tag a new version of the package, see https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app.

If you believe this package has erroneously been detected as not supporting 1.0 or have any other questions, don't hesitate to discuss it here or in the thread linked at the top of this post.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.