--- Log opened Wed Jun 05 00:00:45 2019 | ||
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection] | 07:45 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 07:47 | |
-!- mode/#shogun [+o wiking] by ChanServ | 07:47 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Ping timeout: 248 seconds] | 07:51 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 08:00 | |
-!- mode/#shogun [+o wiking] by ChanServ | 08:00 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection] | 08:40 | |
-!- essam [c5354bbf@gateway/web/freenode/ip.197.53.75.191] has joined #shogun | 09:31 | |
-!- gf712 [90520822@gateway/web/freenode/ip.144.82.8.34] has joined #shogun | 09:57 | |
-!- geektoni [973e1026@gateway/web/freenode/ip.151.62.16.38] has joined #shogun | 10:16 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 11:42 | |
-!- mode/#shogun [+o wiking] by ChanServ | 11:42 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Quit: Leaving...] | 11:57 | |
-!- geektoni [973e1026@gateway/web/freenode/ip.151.62.16.38] has quit [Quit: Page closed] | 12:06 | |
-!- gf712 [90520822@gateway/web/freenode/ip.144.82.8.34] has quit [Ping timeout: 256 seconds] | 12:53 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 13:14 | |
-!- mode/#shogun [+o wiking] by ChanServ | 13:14 | |
@wiking | essam: hey | 13:14 |
---|---|---|
essam | wiking: hi | 13:14 |
@wiking | i think you are wrong | 13:15 |
essam | why | 13:15 |
@wiking | void* sg_realloc(void* ptr, size_t size, const char* file, int line); | 13:15 |
@wiking | template <class T> T* sg_generic_realloc(T* ptr, size_t old_len, size_t len, const char* file, int line) | 13:15 |
@wiking | { | 13:15 |
@wiking | return (T*) sg_realloc(ptr, sizeof(T)*len, file, line); | 13:15 |
@wiking | } | 13:15 |
@wiking | and that is void* p=realloc(ptr, size); | 13:16 |
@wiking | if not using jemalloc or tcmalloc | 13:16 |
essam | what about the sg_realloc in memory.h | 13:17 |
@wiking | yes | 13:17 |
@wiking | check it out | 13:17 |
@wiking | when the one you are referring | 13:17 |
@wiking | is being used | 13:17 |
@wiking | it has a type trait | 13:18 |
@wiking | the one you have copy pasted | 13:18 |
essam | yes you're right | 13:18 |
@wiking | so i would close that issue | 13:19 |
@wiking | about slice pr i'm not really sure | 13:19 |
@wiking | honestly | 13:19 |
essam | but I believe sg_realloc can move the memory | 13:19 |
@wiking | and? | 13:19 |
@wiking | btw | 13:19 |
@wiking | its not a believe system | 13:19 |
essam | what if another SGVector is pointing at it | 13:19 |
@wiking | ;) | 13:19 |
essam | haha sorry :"D check this https://en.cppreference.com/w/c/memory/realloc | 13:20 |
@wiking | git grep resize_vector|wc -l | 13:21 |
@wiking | 62 | 13:21 |
@wiking | mmm have you actually checked how many times resize_vector is being used | 13:21 |
@wiking | ? | 13:21 |
@wiking | i'm just saying | 13:21 |
@wiking | that this is not really an issue | 13:21 |
essam | I thought about since resizing and slicing might be problematic | 13:22 |
@wiking | again | 13:22 |
@wiking | slicing i dont think it makes too much sense | 13:22 |
@wiking | i mean what is the scenario | 13:22 |
@wiking | where you actually wanna use it | 13:22 |
@wiking | ? | 13:22 |
@wiking | or the use-case (that exists) that really requires | 13:22 |
@wiking | that the slice is being referenced | 13:22 |
essam | with dense_dot and other functions that accept raw pointers | 13:22 |
essam | in DotFeatures | 13:22 |
@wiking | yes | 13:22 |
@wiking | still those are usually r/o operations | 13:23 |
@wiking | right? | 13:23 |
essam | there is for example in LibLinear | 13:23 |
@wiking | so you slice the vector | 13:23 |
@wiking | and you do some calc over it | 13:23 |
essam | where you want to do an operation with all the vector except the last element | 13:23 |
@wiking | and that's it | 13:23 |
@wiking | imo this is overengineering | 13:23 |
@wiking | you can access the raw ptr | 13:23 |
@wiking | under SGVector | 13:23 |
@wiking | as they are all public | 13:23 |
@wiking | and the thing you are actually doing that partial free-ing memory | 13:24 |
@wiking | in a slice | 13:24 |
@wiking | is just prone to errors imo | 13:24 |
essam | no partial freeing memory | 13:24 |
essam | it should deallocate all of it | 13:24 |
essam | alright bear with me a second :"D | 13:24 |
@wiking | https://github.com/shogun-toolbox/shogun/pull/4662/files#diff-c02a2e0b28912409b0450601383094e4R404 | 13:25 |
@wiking | sorry man | 13:25 |
@wiking | i'm really not sure all this is necessary | 13:25 |
@wiking | there are way more pressing issues in the lib | 13:25 |
@wiking | than syntactic sugaring the thing | 13:25 |
essam | the problem is that the other pull request, about using SGVectors instead of raw pointers | 13:26 |
-!- mr_sm1th [~mr_sm1th@94-212-245-18.cable.dynamic.v4.ziggo.nl] has joined #shogun | 13:26 | |
@wiking | yes i saw that one | 13:26 |
essam | that will be ugly to do without slicing | 13:26 |
@wiking | what do you mean | 13:26 |
@wiking | sgvector.vector[] | 13:26 |
@wiking | or? :) | 13:26 |
essam | well, we pass an SGVector to a dot operation | 13:26 |
essam | but the dot actually happens with part of the vector | 13:26 |
@wiking | ah coz of linalg | 13:26 |
essam | yes, and because we don't pass the size of the vector | 13:27 |
essam | it's embedded in the SGVector | 13:27 |
essam | so not as much freedom | 13:27 |
essam | why would this deallocate part of the data: https://github.com/shogun-toolbox/shogun/pull/4662/files#diff-c02a2e0b28912409b0450601383094e4R404 | 13:30 |
@wiking | mm mthis actually (slicing) copying the data? | 13:32 |
essam | no | 13:32 |
essam | just adds an offset | 13:32 |
essam | which is then subtracted when deallocated | 13:32 |
@wiking | yes | 13:33 |
@wiking | so | 13:33 |
@wiking | v1(500) | 13:33 |
@wiking | v2 = v1.slice(12,22) | 13:33 |
@wiking | and what happens when v2 gets deallocated? | 13:33 |
essam | depends on the reference counting | 13:33 |
essam | if it's the last one, it will deallocate the whole memory | 13:34 |
@wiking | you call SG_FREE(v1.vector-offset) | 13:34 |
essam | v2.vector - offset = v1.vector | 13:34 |
essam | so it's the same | 13:34 |
@wiking | oh coz u say that v2 could overlive the v1 in some circumstances | 13:35 |
@wiking | so you wanna avoid the case | 13:35 |
essam | yes exactly | 13:36 |
@wiking | mmmm | 13:36 |
@wiking | i'm really not sure | 13:36 |
@wiking | that this is necessary | 13:36 |
@wiking | :) | 13:36 |
@wiking | i mean think about it | 13:36 |
@wiking | you say you operate on a slice of a vector | 13:36 |
@wiking | that's usually because you are not interested in the rest of the vector | 13:36 |
@wiking | that is a loop or something | 13:36 |
@wiking | if you dont copy the mem with the slice (which is the case) | 13:36 |
@wiking | then basically you are having views over a structure | 13:37 |
essam | right | 13:37 |
@wiking | i dont really see an algo design that | 13:37 |
@wiking | keeps longer a view | 13:37 |
@wiking | than the actual data itself | 13:37 |
@wiking | on the other hand | 13:37 |
@wiking | if you start doing this | 13:37 |
@wiking | then plz start thinking about striding | 13:37 |
@wiking | and algining | 13:37 |
@wiking | because these views | 13:38 |
@wiking | could really be a bottleneck if you dont stride them good | 13:38 |
@wiking | just my 2 cents | 13:38 |
@wiking | i mean if you really wanna go down on this rabbit hole | 13:38 |
essam | actually i was thinking the same | 13:38 |
essam | if we do striding, we can also get rid of get_row copying data | 13:38 |
essam | but then linalg would have to change | 13:38 |
essam | to accomodate it | 13:38 |
@wiking | since dot product usually will resolve into a sse2+ register | 13:38 |
@wiking | and if your mem is not aligned | 13:39 |
@wiking | that's like shooting on your leg | 13:39 |
@wiking | coz of the register moves | 13:39 |
essam | i'm not sure i follow :( | 13:39 |
@wiking | ok | 13:39 |
@wiking | so check this | 13:39 |
@wiking | https://stackoverflow.com/questions/52147378/choice-between-aligned-vs-unaligned-x86-simd-instructions | 13:41 |
@wiking | couldn't find better explanation quickly | 13:41 |
@wiking | but basically if you use sse2 or later registers and operations | 13:41 |
@wiking | you wanna have aligned memory | 13:41 |
@wiking | otherwise the moving of the memory to the register | 13:41 |
@wiking | will be slow | 13:41 |
essam | oh I think I understand now | 13:43 |
@wiking | simd are great | 13:43 |
essam | the current use cases of this are just equivalent when done using slicing, but I get your point | 13:43 |
@wiking | and actually eigen linalg will use it a lot | 13:43 |
@wiking | alignment = u wanna introduce strides | 13:44 |
@wiking | that actually the alignment of the memomry | 13:44 |
@wiking | and when you do a slice | 13:44 |
@wiking | you wanna make sure that it's always aligned | 13:44 |
@wiking | see what i mean/ | 13:44 |
@wiking | ? | 13:44 |
@wiking | so say you have 16 bytes alignment | 13:44 |
essam | so if it's not aligned memory should be copied? | 13:44 |
@wiking | but you slice with say 14 bytes | 13:45 |
@wiking | ... see what i mean? | 13:45 |
@wiking | well u wanna pass actually aligned slices | 13:45 |
essam | yes, but how can that be solved without copying and padding? | 13:45 |
@wiking | well | 13:45 |
@wiking | you could actually pass the remainder | 13:46 |
@wiking | but ignore those results | 13:46 |
@wiking | so you actually pass n*alignment for the slice | 13:46 |
essam | sorry, but how striding comes in play? | 13:46 |
-!- geektoni [973e8b3e@gateway/web/freenode/ip.151.62.139.62] has joined #shogun | 16:12 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection] | 16:20 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 16:24 | |
-!- mode/#shogun [+o wiking] by ChanServ | 16:24 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection] | 17:02 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 17:05 | |
-!- mode/#shogun [+o wiking] by ChanServ | 17:05 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Ping timeout: 248 seconds] | 17:10 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 17:12 | |
-!- mode/#shogun [+o wiking] by ChanServ | 17:12 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection] | 17:32 | |
-!- geektoni [973e8b3e@gateway/web/freenode/ip.151.62.139.62] has quit [Quit: Page closed] | 17:41 | |
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun | 19:32 | |
-!- mode/#shogun [+o wiking] by ChanServ | 19:32 | |
-!- wiking [~wiking@huwico/staff/wiking] has quit [Ping timeout: 248 seconds] | 19:36 | |
-!- essam [c5354bbf@gateway/web/freenode/ip.197.53.75.191] has quit [Ping timeout: 256 seconds] | 19:40 | |
-!- mr_sm1th [~mr_sm1th@94-212-245-18.cable.dynamic.v4.ziggo.nl] has quit [Ping timeout: 244 seconds] | 23:37 | |
--- Log closed Thu Jun 06 00:00:46 2019 |
Generated by irclog2html.py 2.10.0 by Marius Gedminas - find it at mg.pov.lt!