IRC logs of #shogun for Wednesday, 2019-06-05

--- 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 #shogun07:47
-!- mode/#shogun [+o wiking] by ChanServ07:47
-!- wiking [~wiking@huwico/staff/wiking] has quit [Ping timeout: 248 seconds]07:51
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun08:00
-!- mode/#shogun [+o wiking] by ChanServ08: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 #shogun09:31
-!- gf712 [90520822@gateway/web/freenode/ip.144.82.8.34] has joined #shogun09:57
-!- geektoni [973e1026@gateway/web/freenode/ip.151.62.16.38] has joined #shogun10:16
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun11:42
-!- mode/#shogun [+o wiking] by ChanServ11: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 #shogun13:14
-!- mode/#shogun [+o wiking] by ChanServ13:14
@wikingessam: hey13:14
essamwiking: hi13:14
@wikingi think you are wrong13:15
essamwhy13:15
@wikingvoid* sg_realloc(void* ptr, size_t size, const char* file, int line);13:15
@wikingtemplate <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
@wikingreturn (T*) sg_realloc(ptr, sizeof(T)*len, file, line);13:15
@wiking}13:15
@wikingand that is void* p=realloc(ptr, size);13:16
@wikingif not using jemalloc or tcmalloc13:16
essamwhat about the sg_realloc in memory.h13:17
@wikingyes13:17
@wikingcheck it out13:17
@wikingwhen the one you are referring13:17
@wikingis being used13:17
@wikingit has a type trait13:18
@wikingthe one you have copy pasted13:18
essamyes you're right13:18
@wikingso i would close that issue13:19
@wikingabout slice pr i'm not really sure13:19
@wikinghonestly13:19
essambut I believe sg_realloc can move the memory13:19
@wikingand?13:19
@wikingbtw13:19
@wikingits not a believe system13:19
essamwhat if another SGVector is pointing at it13:19
@wiking;)13:19
essamhaha sorry :"D check this https://en.cppreference.com/w/c/memory/realloc13:20
@wikinggit grep resize_vector|wc -l13:21
@wiking      6213:21
@wikingmmm have you actually checked how many times resize_vector is being used13:21
@wiking?13:21
@wikingi'm just saying13:21
@wikingthat this is not really an issue13:21
essamI thought about since resizing and slicing might be problematic13:22
@wikingagain13:22
@wikingslicing i dont think it makes too much sense13:22
@wikingi mean what is the scenario13:22
@wikingwhere you actually wanna use it13:22
@wiking?13:22
@wikingor the use-case (that exists) that really requires13:22
@wikingthat the slice is being referenced13:22
essamwith dense_dot and other functions that accept raw pointers13:22
essamin DotFeatures13:22
@wikingyes13:22
@wikingstill those are usually r/o operations13:23
@wikingright?13:23
essamthere is for example in LibLinear13:23
@wikingso you slice the vector13:23
@wikingand you do some calc over it13:23
essamwhere you want to do an operation with all the vector except the last element13:23
@wikingand that's it13:23
@wikingimo this is overengineering13:23
@wikingyou can access the raw ptr13:23
@wikingunder SGVector13:23
@wikingas they are all public13:23
@wikingand the thing you are actually doing that partial free-ing memory13:24
@wikingin a slice13:24
@wikingis just prone to errors imo13:24
essamno partial freeing memory13:24
essamit should deallocate all of it13:24
essamalright bear with me a second :"D13:24
@wikinghttps://github.com/shogun-toolbox/shogun/pull/4662/files#diff-c02a2e0b28912409b0450601383094e4R40413:25
@wikingsorry man13:25
@wikingi'm really not sure all this is necessary13:25
@wikingthere are way more pressing issues in the lib13:25
@wikingthan syntactic sugaring the thing13:25
essamthe problem is that the other pull request, about using SGVectors instead of raw pointers13:26
-!- mr_sm1th [~mr_sm1th@94-212-245-18.cable.dynamic.v4.ziggo.nl] has joined #shogun13:26
@wikingyes i saw that one13:26
essamthat will be ugly to do without slicing13:26
@wikingwhat do you mean13:26
@wikingsgvector.vector[]13:26
@wikingor? :)13:26
essamwell, we pass an SGVector to a dot operation13:26
essambut the dot actually happens with part of the vector13:26
@wikingah coz of linalg13:26
essamyes, and because we don't pass the size of the vector13:27
essamit's embedded in the SGVector13:27
essamso not as much freedom13:27
essamwhy would this deallocate part of the data: https://github.com/shogun-toolbox/shogun/pull/4662/files#diff-c02a2e0b28912409b0450601383094e4R40413:30
@wikingmm mthis actually (slicing) copying the data?13:32
essamno13:32
essamjust adds an offset13:32
essamwhich is then subtracted when deallocated13:32
@wikingyes13:33
@wikingso13:33
@wikingv1(500)13:33
@wikingv2 = v1.slice(12,22)13:33
@wikingand what happens when v2 gets deallocated?13:33
essamdepends on the reference counting13:33
essamif it's the last one, it will deallocate the whole memory13:34
@wikingyou call SG_FREE(v1.vector-offset)13:34
essamv2.vector - offset = v1.vector13:34
essamso it's the same13:34
@wikingoh coz u say that v2 could overlive the v1 in some circumstances13:35
@wikingso you wanna avoid the case13:35
essamyes exactly13:36
@wikingmmmm13:36
@wikingi'm really not sure13:36
@wikingthat this is necessary13:36
@wiking:)13:36
@wikingi mean think about it13:36
@wikingyou say you operate on a slice of a vector13:36
@wikingthat's usually because you are not interested in the rest of the vector13:36
@wikingthat is a loop or something13:36
@wikingif you dont copy the mem with the slice (which is the case)13:36
@wikingthen basically you are having views over a structure13:37
essamright13:37
@wikingi dont really see an algo design that13:37
@wikingkeeps longer a view13:37
@wikingthan the actual data itself13:37
@wikingon the other hand13:37
@wikingif you start doing this13:37
@wikingthen plz start thinking about striding13:37
@wikingand algining13:37
@wikingbecause these views13:38
@wikingcould really be a bottleneck if you dont stride them good13:38
@wikingjust my 2 cents13:38
@wikingi mean if you really wanna go down on this rabbit hole13:38
essamactually i was thinking the same13:38
essamif we do striding, we can also get rid of get_row copying data13:38
essambut then linalg would have to change13:38
essamto accomodate it13:38
@wikingsince dot product usually will resolve into a sse2+ register13:38
@wikingand if your mem is not aligned13:39
@wikingthat's like shooting on your leg13:39
@wikingcoz of the register moves13:39
essami'm not sure i follow :(13:39
@wikingok13:39
@wikingso check this13:39
@wikinghttps://stackoverflow.com/questions/52147378/choice-between-aligned-vs-unaligned-x86-simd-instructions13:41
@wikingcouldn't find better explanation quickly13:41
@wikingbut basically if you use sse2 or later registers and operations13:41
@wikingyou wanna have aligned memory13:41
@wikingotherwise the moving of the memory to the register13:41
@wikingwill be slow13:41
essamoh I think I understand now13:43
@wikingsimd are great13:43
essamthe current use cases of this are just equivalent when done using slicing, but I get your point13:43
@wikingand actually eigen linalg will use it a lot13:43
@wikingalignment = u wanna introduce strides13:44
@wikingthat actually the alignment of the memomry13:44
@wikingand when you do a slice13:44
@wikingyou wanna make sure that it's always aligned13:44
@wikingsee what i mean/13:44
@wiking?13:44
@wikingso say you have 16 bytes alignment13:44
essamso if it's not aligned memory should be copied?13:44
@wikingbut you slice with say 14 bytes13:45
@wiking... see what i mean?13:45
@wikingwell u wanna pass actually aligned slices13:45
essamyes, but how can that be solved without copying and padding?13:45
@wikingwell13:45
@wikingyou could actually pass the remainder13:46
@wikingbut ignore those results13:46
@wikingso you actually pass n*alignment for the slice13:46
essamsorry, but how striding comes in play?13:46
-!- geektoni [973e8b3e@gateway/web/freenode/ip.151.62.139.62] has joined #shogun16:12
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection]16:20
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun16:24
-!- mode/#shogun [+o wiking] by ChanServ16:24
-!- wiking [~wiking@huwico/staff/wiking] has quit [Remote host closed the connection]17:02
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun17:05
-!- mode/#shogun [+o wiking] by ChanServ17:05
-!- wiking [~wiking@huwico/staff/wiking] has quit [Ping timeout: 248 seconds]17:10
-!- wiking [~wiking@huwico/staff/wiking] has joined #shogun17:12
-!- mode/#shogun [+o wiking] by ChanServ17: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 #shogun19:32
-!- mode/#shogun [+o wiking] by ChanServ19: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!