Re: atomics: Why is interlockedCompareExchange8

2017-11-27 Thread mratsim
@Udiknedormin: I meant right now, since VTable are not available of course. @monster: It is not safe as is, you must ensure your chain of Msg and MsgBase pointers have the same lifetime (by putting them in a seq for example). Otherwise if they are created in different functions, the previous Msg

Re: Copy-on-write container

2017-11-27 Thread mratsim
Yes, it's possible to have a Tensor of x, y, z points. Sorting is not implemented yet. (And will not be implemented in terms of map/parallel map but in terms of whatever algo I find the fastest/most memory efficient).

constness of refs & ptrs

2017-11-27 Thread sendell
I was going to talk about this on IRC but I figured out a post would be more appropriate. This is also my first post on this forum so _hello, nim-community_. I usually don't get involved in such stuff, but since Nim is running towards 1.0 and I have huge expectations for it, I'm making an effor

Re: atomics: Why is interlockedCompareExchange8

2017-11-27 Thread monster
I want to not only send those messages between threads, but also across the network. Anything containing additional pointers would just make things more complicated. Atm, I'm trying something like this (not entirely sure if toMsgBasePtr() is safe): type QueueID* = distinct ui

Re: atomics: Why is interlockedCompareExchange8

2017-11-27 Thread Udiknedormin
That is not true. Vtable pointers can be elements of a seq, just like any ptr or ref type.

Re: Copy-on-write container

2017-11-27 Thread Udiknedormin
What I mean is a vectorized structure-of-arrays for x, y, z (and possibly others) for a set of particles. They should be ordered according to their place in space grid. As I said, in numpy I can have a any-D numpy array and sort it, no python lists involved. I imagine the same for tensors in Arr

Re: Copy-on-write container

2017-11-27 Thread mratsim
I'm not sure we are speaking of the same thing. In which case are we: a Tensor containing seqs or a pure rank 2 (matrix) or rank 3 tensor? import arraymancer import sequtils, random let p1 = newSeqWith(4, random(0..10)) let p2 = newSeqWith(4, random(0..10))

Re: atomics: Why is interlockedCompareExchange8 "safe"?

2017-11-27 Thread mratsim
No, they are not, it would work only if seq[YourConcept] is not needed or only of homogeneous concrete type.

Re: atomics: Why is interlockedCompareExchange8 "safe"?

2017-11-27 Thread Udiknedormin
@mratsim Vtptrs are not ready yet, as I've heard? If they were, I guess they would solve the problem (it is how it would probably be solved in Rust, actually).

Re: Copy-on-write container

2017-11-27 Thread Udiknedormin
Let's say I want to do some operations on particles. They should be vectorized (and maybe parallelized, some calculations could also benfit from GPU) and it would be really nice if particles from the same space grid would be in the same place in the sequence, as they will need to access the same

Re: Compiling with --gc:none produces unexpected prohibition

2017-11-27 Thread jzakiya
This code works as desired in parallel. Thanks for the instructions. proc column_load(prime, j, k, r: int) {.gcsafe.} = {.gcsafe.}: for ri in residues: # for each prime|residue pair let prod = r * ri # compute res cross

Re: atomics: Why is interlockedCompareExchange8 "safe"?

2017-11-27 Thread mratsim
Also could concepts fit your need?

Re: Do we have a RTree or R*Tree for Nim?

2017-11-27 Thread mratsim
As far as I know there is none. I'm interested in a pure Nim implementation of R-tree and closely related [Kd-tree](https://en.wikipedia.org/wiki/K-d_tree) for geospatial algorithms (clustering especially). I've added your suggestion to the "[Are we scientists yet](https://github.com/nim-lang/

Re: atomics: Why is interlockedCompareExchange8 "safe"?

2017-11-27 Thread monster
The number of message types is not fixed. I'm trying something else now, using composition instead of inheritance.

Re: Copy-on-write container

2017-11-27 Thread mratsim
In which cases would you need to store a seq or a list in a tensor or a Numpy ndarray?

Do we have a RTree or R*Tree for Nim?

2017-11-27 Thread Stefan_Salewski
[https://en.wikipedia.org/wiki/R-tree](https://en.wikipedia.org/wiki/R-tree) I assume not yet. For Ruby I used my custom bindings to boost library for this. But as the RTree algorithm is not too complex, a native Nim implementation may be preferable over a Nim Boost-Rtree wrapper. I guess we w

Re: Nim on Android

2017-11-27 Thread sdwfrost
Thanks @hawk_king ; this worked with the addition of the extra line in your earlier post echo 'passL=" -landroid-glob "' >> config/nim.cfg

Re: atomics: Why is interlockedCompareExchange8 "safe"?

2017-11-27 Thread Udiknedormin
@monster Is the number of different kinds of messages fixed? If it is, you can use variant types.

Re: Copy-on-write container

2017-11-27 Thread Udiknedormin
@mratsim Oh, really, you don't know any example of an operation the cost of depends on values? Well, I easily know one: sorting.

Re: An orientation document to the "mainstream" developer

2017-11-27 Thread Udiknedormin
It seems a little messy, I'd say. And not really too many examples. I think you should make up your mind: do you want people to get interested in Nim (=> you don't really have to explain things that much) or do you want to teach them Nim (=> you make a "tutorial for experienced programmers").

Re: local-heap/multi-threading not working as I expect

2017-11-27 Thread boia01
I see what you're saying... but Nim's design is different. There is no invisible synchronization for globals. They are unsafe if you mutate them (usual "shared xor mutable" disclaimer). If you are going to mutate shared state, you must take appropriate precautions (locks, memory barriers, etc.)