hkaiser changed the topic of #ste||ar to: STE||AR: Systems Technology, Emergent Parallelism, and Algorithm Research | stellar.cct.lsu.edu | HPX: A cure for performance impaired parallel applications | github.com/STEllAR-GROUP/hpx | Buildbot: http://rostam.cct.lsu.edu/ | Log: http://irclog.cct.lsu.edu/
jpenuchot has joined #ste||ar
diehlpk has joined #ste||ar
eschnett has joined #ste||ar
diehlpk has quit [Ping timeout: 252 seconds]
nikunj has quit [Ping timeout: 268 seconds]
K-ballo has quit [Quit: K-ballo]
nikunj has joined #ste||ar
nikunj has quit [Read error: Connection reset by peer]
nikunj97 has joined #ste||ar
hkaiser has quit [Quit: bye]
eschnett has quit [Quit: eschnett]
bita has quit [Ping timeout: 244 seconds]
tianyi93 has quit [Ping timeout: 252 seconds]
nanxiao has joined #ste||ar
nanxiao has quit [Client Quit]
jpenuchot has quit [Remote host closed the connection]
<Yorlik> Hmm .. I think I just caught my first race condition: Deferring a cout call to another thread containing a string argument thats racing out of scope.
<Yorlik> future came to the rescue :)
<Yorlik> Though it looks moderately weird: H_OUT("Evaluating \""<<input<<"\""<<endl).get();
<Yorlik> Which makes me asking again what's the best way to wrap cout withing HPX to get non interleaved output (on a character level - tasks/threads ofc still interleave.)
<Yorlik> Seems a future inside a lambda inside a lock_guard wrapper is not a good idea ... Seems my toddler walks are leading me straight into the lands of the dragons and pink elephants.
quaz0r has quit [Ping timeout: 246 seconds]
quaz0r has joined #ste||ar
quaz0r has quit [Ping timeout: 252 seconds]
quaz0r has joined #ste||ar
david_pfander has joined #ste||ar
<jbjnr__> Yorlik: there is a special hpx::cout that you can use that does it 'right'
<Yorlik> Thanks !
<jbjnr__> all mesages are transferred to the root node and then printed without messy overlaps
<Yorlik> I knew about it, but wanted to learn the ropes here.
<jbjnr__> if running a single node, then it just makes sure messages are not munged
<jbjnr__> to learn the ropes, look a the hpx::cout code then :)
<Yorlik> E.g. when doing logging or anything special I need to understand the mechanics (though HPX has logging already, right?)
<jbjnr__> it does, but nobody uses it much
<Yorlik> I'll get into that later - but löooking at hpc::cout is a good idea
<Yorlik> hpx:: ..
<Yorlik> Newbie Question: If I have a base class with a constructor taking a string argument - how can I use this from a derived class? It seems not to work automagically.
<Yorlik> E.G. new ( &storage::data_ [ slot ] ) ENT_T ( id ) ; this does not work, if id is expected by the constructor of ENT_Ts parent class
<simbergm> heller_ yep, we should definitely apply, maybe they'll feel sorry about us not getting accepted to gsoc (I wish it was that easy...)
<heller_> ;)
<Yorlik> Just realized I can store stuff in a class without a single member being instantiated (static vector member). Now how would I loop over the different class types ? Would I need typelists?
K-ballo has joined #ste||ar
<Yorlik> K-ballo: Do you have an idea how to extend that trick with the vector<T> to do something for all these vectors of the various Ts?
<Yorlik> I tried using wrapper classes, until I understood they never get instantiated as long as the vector is static
<Yorlik> I think it kind boils down to looping over a set of template instantiations
hkaiser has joined #ste||ar
<Yorlik> Is there any way to have something like a global initializer code for a class that runs on application start, even when there are no instances?
<Yorlik> Something like a constructor, just without construction. Static Constructor might be an appropriate term.
<hkaiser> Yorlik: sure
<Yorlik> How would you do that ?
<K-ballo> you need an instance, an instance of something
<Yorlik> Haaaaaa
<K-ballo> constructors for globals run on startup
<hkaiser> create a global instance of a type that initializes what you need in its constructor
<Yorlik> Thats what I try to avoid
<hkaiser> why?
<Yorlik> I am trying to find a way to create a collection of all specialized containers created with this k-ballo trick from yesterday
<hkaiser> statics are initialized at startup as well
<Yorlik> E.g. if I use something like template<typename T> myvecs; and do sth like myvecs<mytype>.emplace_back() I have no way to loop over all the myvecs I created
<Yorlik> I would need a loop over the different types
<Yorlik> I am not sure if the generic way is best to solve what I want to do, I'm just trying to learn whats possible.
<Yorlik> Application is the update loop, where i need to update all types
<Yorlik> type instances that is
<hkaiser> Yorlik: same procedure
* Yorlik stumbles and toddles ...
<hkaiser> create a static member of your class, make sure it is initialized after the vector and let it register the vector in your registry during its construction
<Yorlik> You mean the initialization function for that member would be a template doing the registration?
<Yorlik> Thats actually interesting. It would allow me d to launch a function only for instantiated templates
<Yorlik> I'll try that
<hkaiser> Yorlik: you would need a polymorphic registry for that, I think
<Yorlik> I use an Interface they inherit from
<hkaiser> ok
<Yorlik> its just pointers
<hkaiser> uhh
<hkaiser> *shiver*
<Yorlik> What scares you ?
<hkaiser> pointers
<Yorlik> I'm not doing any weird indirections
<hkaiser> *sure*
<Yorlik> I never act on pointers - they are just references for reading
<Yorlik> And in this case on permanent ob jects - they live until shutdown
bibek has joined #ste||ar
<Yorlik> I think we have a valid case for a singleton here.
<K-ballo> the very first one that must be!
<hkaiser> Yorlik: in that case a reference would do instead of a pointer
* Yorlik digs some more
<Yorlik> K-ballo - I might just kill the highlander - lol
eschnett has joined #ste||ar
eschnett has quit [Client Quit]
<zao> Static lifetimes, ugh.
aserio has joined #ste||ar
<Yorlik> hkaiser, K-ballo: https://godbolt.org/z/3N6e5u :)
<Yorlik> No singletons
<Yorlik> The Highlander go killed...
<Yorlik> Warning: Dirty code ahead.
<K-ballo> ok, for some definition of "singleton", sure
<K-ballo> so it works as expected?
<Yorlik> Yes
<Yorlik> It took me a while to get the initializer triggered and work correctly
<Yorlik> But it does what it's expected to do
<K-ballo> the vector<vector<E>*> looks odd
<Yorlik> And in main(9 I can finally loop over the vectors and output the content
<Yorlik> This one is the master storage
<Yorlik> it keeps pointers to the polymorphic vectors
<K-ballo> those vectors don't look polymorphic
<Yorlik> the are keeping different types
<Yorlik> E1 and E2 are different types
<K-ballo> if they were then you couldn't get a pointer to vector<E>
<Yorlik> I cast the pointer
<K-ballo> aha? UB
<Yorlik> Not really
<K-ballo> no, really
<Yorlik> It's just a reference
<K-ballo> you can't go from vector<Derived>* to vector<Base>*
<Yorlik> I am not slicing objects here
<K-ballo> no, slicing is well defined, what you are doing is plain undefined behavior
<Yorlik> What could happen?
<Yorlik> This is not a finished interface or anything and there are no safeguards anywhere
<K-ballo> nasal deamons
<zao> T<X> and T<Y> are completely unrelated types unless they have a relationship in some other way (inheritance etc.)
<K-ballo> you are corrupting those vectors memories
<K-ballo> by using them as if they had a type that they do not
<Yorlik> Checking ...
<Yorlik> Not sure if its UB or just a stupid bug
<K-ballo> terminate called after throwing an instance of 'std::logic_error'
<K-ballo> what(): basic_string::_M_construct null not valid
<zao> None of the meaningful reinterpretations apply there, like "casting an object pointer to a pointer of its first member" etc.
<K-ballo> it's trying to read a string id_ from random memory
<K-ballo> because it thinks the memory contains E (the base type)
<Yorlik> Yes - it would require casting it back
<Yorlik> the write operations I'm doing are using the correct types I think.
<zao> Might as well hold things by void* if you can't legally use anything about the type.
<Yorlik> It absolutely needs a rework if it shall be usable
<K-ballo> the write operations might be fine, the cast from vector<Ex>* to vector<E>* is what's UB
<Yorlik> Yes - the middle of the loop is wonky
<Yorlik> They simply need a shared interface
<Yorlik> e.g. E1 and E2 have additional data which messes it all up
<Yorlik> I'll find a way to tie it all together safely.
<K-ballo> here's a (non-ideal) idea..
<K-ballo> instead of keeping a pointer to your vector, keep a type erased function that iterates over it
<K-ballo> a function that when run walks over the vector and calls some other thing with each element casted to the base
<Yorlik> In the real application there will only be functions tailored for the derived type working on the vectors
<Yorlik> Normally they never get put together and mistreated like I did here.
<Yorlik> I think I'll make the functions which will work in the update loop specialized templates. However the construction is not exactly safe like it is.
<Yorlik> It's funny - compiling in VS and running it on Windows I get no warnings or issues whatsoever - it's UBing along jolly all the way ;)
<Yorlik> Which is frightening
<K-ballo> yeap, that is what UB is
<K-ballo> note I "cheated", I added state to E1 and E2
<Yorlik> double and int - saw it
<Yorlik> In the core loop only data belonging to the base class is accessed and still it explodes - which is evil, but correct it seems. I will probably make that vector which holds it all together a map which maps the vectors to a typecoide
<Yorlik> So the update functions would pick the correct vector for their type by that code and then loop over it
<Yorlik> Knowing which type is in it
<Yorlik> I already made specialized templates which work like typeFromBitMask<uint64_t mask>::type
<K-ballo> you are forcing the compiler to reinterpret an E1[] bunch of memory as if it were an E[] bunch of memory
<K-ballo> since they have different sizes, that goes bad fast
<Yorlik> That loop in this test will never happen in what we do
<Yorlik> I'm aware it's dangerous code - so I need to seal all the dangerous stuff away
<K-ballo> as zao said, you might as well hold things by void*, since you can't ever touch those vectors without casting first
<Yorlik> In the end the vectors are typed and all is orderly
<Yorlik> True - void would have the advantage to make the danger more explicit
<Yorlik> After all a vector<E> * looks sweet and nice, rigfht?
<Yorlik> :D
<Yorlik> Better explicitely void it
<Yorlik> So we get proper instant explosions
<Yorlik> The exercise here for me was to have this static initialization and registration
<zao> Either void or hold something type erased that has any operations you may want, like size() etc
<Yorlik> And that works nicely - now I just have to make it safe.
<Yorlik> I'll have to think more about it, for now i have a start.
hkaiser has quit [Quit: bye]
<Yorlik> type erasure is a new concept to me - I'd have to learn it first. It's in boost, right ?
<K-ballo> there is a boost library called type erasure, yes.. but type erasure is all around you, it takes many formms
<K-ballo> your E interface is a form of type erasure too, as it lets you operate on E1, E2, E3, without actually having their types reflected in the type system
<Yorlik> I always thought you could always downcast a derived to its base
<K-ballo> that's not down, but sure you can
<K-ballo> casting from Base& to Derived& is a completely different beast than casting from Base (&)[] to Derived (&)[]
<Yorlik> So - if you have a bunch of derived instances and you only know their base - can't you at least use the common interface?
<Yorlik> BTW - it now explodes here too after adding some members
<K-ballo> you can but how do you find them in the first place?
<Yorlik> I naively thought the data layout was determined by the chain of inheritence
<K-ballo> you know the first Base lives at offset 0, but what do you know about the second Base? it lives anywhere >= sizeof(Base)
<Yorlik> So you could always deduce back - but thats obviously wrong
<Yorlik> The anywhere is what I didn't know
<Yorlik> I believed there were a clear offset you could calculate from size, alignment ruels and such
<K-ballo> sure there is, if you know the type
<K-ballo> but you erased the type
<Yorlik> So - what I added comes at offset 0, not the base?
<Yorlik> I'd probably just start with the most general data and then add the more specialized data later on
<Yorlik> But obviously thats not the case.
<K-ballo> ?
<K-ballo> the stride between elements in an array(vector) of T is always sizeof(T)
<Yorlik> My -wrong- idea was, if you have a: b, c, d, the data layout would be b-c-d-a
<K-ballo> there's a disconnect somewhere, that part isn't relevant
<Yorlik> Lets say there would be no multiple inheritance and you hve a:b:c, c would be the superclass and I'd expect a layout of c at 0 then b and t5hen a
<K-ballo> you are overcomplicating it
<Yorlik> However - I got it wrng and makde wrong assumptions
<K-ballo> you have Base with sizeof 1, and Derived : Base with sizeof 2... you have an array of Derived, so one Derived after the next, and you reinterpret that memory as an array of Base, one Base after the next.. Base is half the size of Derived, as you reinterpret the memory you attempt to read two Base objects for each Derived
<Yorlik> Oh crap - lol
<K-ballo> the nth element in a Base array is at n*sizeof(Base), the nth element in a Derived array is at n*sizeof(Derived)
<Yorlik> I guess I understand now
<Yorlik> All the offsets were jumbled up
<K-ballo> yes
<K-ballo> well, except the 0th one
<Yorlik> There can only be one
<Yorlik> You see - the Singletonlander is back again !
<Yorlik> Sneaky bastard ...
<Yorlik> However - I need a break now
<Yorlik> Tnaks a ton for the patient explanations.
<Yorlik> I'll be back later...
* Yorlik waves and fades
bita has joined #ste||ar
eschnett has joined #ste||ar
<jbjnr__> K-ballo: howcan I have an inline function in class B that needs class A, (but class A, needs class B defined first). So it's circular. If I move the function from the header to the cpp, then all is fine, but then it won't be inline.
<jbjnr__> can a function in the cpp file be declared inline
<jbjnr__> (since the oher files that use it, can't see it, I assume not)
<K-ballo> inline in a cpp file doesn't mean much
<K-ballo> inline in general doesn't mean much either
<jbjnr__> is there a trick I can use for this kind of thing
<jbjnr__> by inline, I just mean, optimize it in place wihout a function call if possible please mr compiler
<K-ballo> define the inline function in its own header, then have both A and B headers include it at the right time
<K-ballo> does A include B and viceversa already?
<K-ballo> or is the user the one that gets to decide if it includes either or both?
<jbjnr__> A includes B, but B doesn't include a, I wanted to forward declare A in B, but it's too big and messy
<jbjnr__> and some inline functions are present
<jbjnr__> I moved some code around and got myself into a mess
<K-ballo> you have some sort of cyclic condition to begin with..
<K-ballo> you can have both A and B headers check whether the other one has been included already
<jbjnr__> I'll play thanks
<Guest70467> why omp_get_place_num return bigger than sockets max num?
<jbjnr__> Guest70467: you may have the wrong irc channel for that question.
<Guest70467> so which channel should ?
<jbjnr__> an openmp related one?
<jbjnr__> this is hpx
<Guest70467> I don't know it's id.
<jbjnr__> from the sound of it I'd guess that you are getting the core id, but that may be larger than the number of sockets
<Guest70467> no
<Guest70467> I get socket id where thread bind
<Guest70467> like example 1
<Guest70467> I just have 2 sockets, but I get >2 socket id
<zao> Guest70467: Are you doing this as part of some ste||ar project?
<Guest70467> yes
hkaiser has joined #ste||ar
jaafar has quit [Ping timeout: 252 seconds]
<bita> hkaiser, sorry, I didn't see that. That is exactly as you said. In a 3d array, having `axis=(1,2)` means doing the operation on the pageslices, so for `np.var([[[1,2],[3,4]],[[11,12],[13,14]]],axis=(1,2))` we get `[ 1.25, 1.25]`
<bita> ( axis=(0,1) is operating on columnslices and axis=(0,2) is operating on rowslices)
<hkaiser> bita: thanks
david_pfander has quit [Ping timeout: 246 seconds]
jaafar has joined #ste||ar
<heller_> hkaiser: hey, do we want to chat today?
aserio1 has joined #ste||ar
aserio has quit [Ping timeout: 252 seconds]
aserio1 is now known as aserio
aserio has quit [Quit: aserio]
aserio has joined #ste||ar
aserio has quit [Ping timeout: 252 seconds]
<zao> Sounds like GCC prior to 7 is silly.
<K-ballo> so what does that mean for us?
<zao> I'm not sure yet, but it might imply that we need -mcx16 on those earlier compilers/stdlibs?
<zao> In general, I'm a bit scared about the talk about libatomic emulating operations with mutexes.
<K-ballo> that is what libatomic is for, the operations that cannot be lowered and have to be "emulated" (atomic does not mean lock-free)
<zao> If that's expected, then yay, no problem.
<K-ballo> that's why the problem goes away when we specify -mcx16
<K-ballo> I don't know what that means for that queue, I never did understand it
<K-ballo> it was going to be removed, but then it found its way back in somehow
hkaiser has quit [Quit: bye]
bibek has quit [Quit: Konversation terminated!]
aserio has joined #ste||ar
<K-ballo> is master broken?
<K-ballo> odd, I'm suddenly getting boost related linker errors
eschnett has quit [Quit: eschnett]
<K-ballo> I bet is auto linking inflicted..
<zao> Windows?
<K-ballo> yes
<K-ballo> getting redefinitions for linking against both shared and static
<zao> Ooh, build failure.
<zao> Hecking examples.
<zao> `/home/zao/stellar/repos/hpx/examples/quickstart/component_with_custom_heap.cpp:86:17: error: reinterpret_cast from type ‘const allocator::alloc_block<hello_world_server>*’ to type ‘char*’ casts away qualifiers`
<K-ballo> -Wnoexcept-type was bogus, it got retired
<zao> It's present in my GCC 7.3.0 on our master.
<K-ballo> yeah, gone in 8.0.0
<zao> This example seems very broken in C++11.
<zao> I guess no-one ever builds them.
<K-ballo> there was a recent PR to fix those, did it make it?
<zao> Gah, completely unrelated PR title.
<K-ballo> yep, fix entangled with it
<K-ballo> clean cmake cache builds fine, we really need to stop relaing on boost autolinking
aserio has quit [Quit: aserio]
hkaiser has joined #ste||ar
eschnett has joined #ste||ar
eschnett has quit [Quit: eschnett]
<Yorlik> o/
<Yorlik> K-ballo - I really had to laugh later about this "loop of doom" of mine which turned out to be a formidable data shredder
<Yorlik> I had already been coding for hours and my brain was in a sort of UB state itself.
<Yorlik> But I really like this idea of hkaiser, to essentially abuse side effects of functions to trigger initialization work for types
<Yorlik> It links together what you do at compile time with types and generics nicely with runtime work.
<Yorlik> Time to turn the shredder into something useful now ...
* Yorlik goes into heads down mode
jbjnr__ has quit [Read error: Connection reset by peer]
jaafar has quit [Ping timeout: 252 seconds]