{"action":"created","issue":{"url":"https://api.github.com/repos/flame/blis/issues/68","repository_url":"https://api.github.com/repos/flame/blis","labels_url":"https://api.github.com/repos/flame/blis/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/flame/blis/issues/68/comments","events_url":"https://api.github.com/repos/flame/blis/issues/68/events","html_url":"https://github.com/flame/blis/issues/68","id":150297399,"number":68,"title":"multi thread crash","user":{"login":"songmaotian","id":12146033,"avatar_url":"https://avatars.githubusercontent.com/u/12146033?v=3","gravatar_id":"","url":"https://api.github.com/users/songmaotian","html_url":"https://github.com/songmaotian","followers_url":"https://api.github.com/users/songmaotian/followers","following_url":"https://api.github.com/users/songmaotian/following{/other_user}","gists_url":"https://api.github.com/users/songmaotian/gists{/gist_id}","starred_url":"https://api.github.com/users/songmaotian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/songmaotian/subscriptions","organizations_url":"https://api.github.com/users/songmaotian/orgs","repos_url":"https://api.github.com/users/songmaotian/repos","events_url":"https://api.github.com/users/songmaotian/events{/privacy}","received_events_url":"https://api.github.com/users/songmaotian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-04-22T07:53:01Z","updated_at":"2016-04-27T00:17:29Z","closed_at":null,"body":"Hello, \r\n      It seems libblis is not thread safe, I have a gemm invocation\r\n```\r\nstatic inline void matmul(cv::Mat &c, cv::Mat &a, cv::Mat b)\r\n{\r\n        float   alphap = 1.0;\r\n        //since beta is zero, we don't need to init c to zero\r\n        float   betap = 0.0;\r\n\r\n        cntx_t cntx;\r\n        bli_gemm_cntx_init(&cntx);\r\n\r\n        bli_sgemm(BLIS_NO_TRANSPOSE, BLIS_NO_TRANSPOSE, a.rows, b.cols, a.cols,\r\n                &alphap,\r\n                (float *)a.data, a.cols, 1,\r\n                (float *)b.data, b.cols, 1,\r\n                &betap,\r\n                (float *)c.data, b.cols, 1, &cntx);\r\n        bli_gemm_cntx_finalize(&cntx);\r\n}\r\n```\r\nand we have several thread will invoke the matmul, then it will crash as follow, the parameter p get changed to 0, if I change the program to run only one thread to invoke the matmul, it will be all right.\r\n\r\n#0  0x0000000000545abc in bli_spackm_6xk_ref (conja=BLIS_NO_CONJUGATE, n=25, kappa=0x7fffec000dc0, a=0x7fffb8091540, inca=25, lda=1, p=0x0, ldp=6)\r\n    at frame/1m/packm/ukernels/bli_packm_cxk_ref.c:414\r\n#1  0x00000000004ee461 in bli_spackm_cxk (conja=BLIS_NO_CONJUGATE, panel_dim=6, panel_len=25, kappa=0x7fffec000dc0, a=0x7fffb8091540, inca=25, lda=1, p=0x0, ldp=6, \r\n    cntx=0x7fffd247c190) at frame/1m/packm/bli_packm_cxk.c:216\r\n#2  0x00000000004c4806 in bli_spackm_struc_cxk (strucc=BLIS_GENERAL, diagoffc=0, diagc=BLIS_NONUNIT_DIAG, uploc=BLIS_DENSE, conjc=BLIS_NO_CONJUGATE, \r\n    schema=BLIS_PACKED_COL_PANELS, invdiag=0, m_panel=25, n_panel=6, m_panel_max=25, n_panel_max=6, kappa=0x7fffec000dc0, c=0x7fffb8091540, rs_c=1, cs_c=25, p=0x0, \r\n    rs_p=6, cs_p=1, is_p=1, cntx=0x7fffd247c190) at frame/1m/packm/bli_packm_struc_cxk.c:255\r\n#3  0x00000000004bbbe6 in bli_spackm_blk_var1 (strucc=BLIS_GENERAL, diagoffc=0, diagc=BLIS_NONUNIT_DIAG, uploc=BLIS_DENSE, transc=BLIS_NO_TRANSPOSE, \r\n    schema=BLIS_PACKED_COL_PANELS, invdiag=0, revifup=0, reviflo=0, m=25, n=1936, m_max=25, n_max=1938, kappa=0x7fffec000dc0, c=0x7fffb8091540, rs_c=1, cs_c=25, p=0x0, \r\n    rs_p=6, cs_p=1, is_p=1, pd_p=6, ps_p=150, packm_ker=0x4c46f9 <bli_spackm_struc_cxk>, cntx=0x7fffd247c190, thread=0x7fffb8007600)\r\n    at frame/1m/packm/bli_packm_blk_var1.c:668\r\n#4  0x00000000004bb133 in bli_packm_blk_var1 (c=0x7fffd2479e50, p=0x7fffd24798e0, cntx=0x7fffd247c190, t=0x7fffb8007600) at frame/1m/packm/bli_packm_blk_var1.c:234\r\n#5  0x00000000004aed11 in bli_packm_int (a=0x7fffd2479e50, p=0x7fffd24798e0, cntx=0x7fffd247c190, cntl=0x7fffec002c00, thread=0x7fffb8007600)\r\n    at frame/1m/packm/bli_packm_int.c:125\r\n#6  0x00000000004b23ca in bli_gemm_blk_var1f (a=0x7fffd2479d80, b=0x7fffd2479e50, c=0x7fffd2479f20, cntx=0x7fffd247c190, cntl=0x7fffec002d00, thread=0x7fffb8007660)\r\n    at frame/3/gemm/bli_gemm_blk_var1f.c:79\r\n#7  0x00000000004488b2 in bli_gemm_int (alpha=0x7c66a0 <BLIS_ONE>, a=0x7fffd247a160, b=0x7fffd247a230, beta=0x7c66a0 <BLIS_ONE>, c=0x7fffd247a090, cntx=0x7fffd247c190, \r\n    cntl=0x7fffec002d00, thread=0x7fffb8007660) at frame/3/gemm/bli_gemm_int.c:154\r\n#8  0x00000000004b304b in bli_gemm_blk_var3f (a=0x7fffd247a530, b=0x7fffd247a600, c=0x7fffd247a6d0, cntx=0x7fffd247c190, cntl=0x7fffec002da0, thread=0x7fffb80c0ae0)\r\n    at frame/3/gemm/bli_gemm_blk_var3f.c:121\r\n#9  0x00000000004488b2 in bli_gemm_int (alpha=0x7c66a0 <BLIS_ONE>, a=0x7fffd247a840, b=0x7fffd247a910, beta=0x7c66a0 <BLIS_ONE>, c=0x7fffd247a9e0, cntx=0x7fffd247c190, \r\n    cntl=0x7fffec002da0, thread=0x7fffb80c0ae0) at frame/3/gemm/bli_gemm_int.c:154\r\n#10 0x00000000004b2b28 in bli_gemm_blk_var2f (a=0x7fffd247ace0, b=0x7fffd247adb0, c=0x7fffd247ae80, cntx=0x7fffd247c190, cntl=0x7fffec002e40, thread=0x7fffb80c0ca0)\r\n    at frame/3/gemm/bli_gemm_blk_var2f.c:123\r\n#11 0x00000000004488b2 in bli_gemm_int (alpha=0x7fffd247bcf0, a=0x7fffd247b0c0, b=0x7fffd247b190, beta=0x7fffd247bf60, c=0x7fffd247b260, cntx=0x7fffd247c190, \r\n    cntl=0x7fffec002e40, thread=0x7fffb80c0ca0) at frame/3/gemm/bli_gemm_int.c:154\r\n#12 0x0000000000423d60 in bli_level3_thread_decorator (n_threads=1, func=0x447f75 <bli_gemm_int>, alpha=0x7fffd247bcf0, a=0x7fffd247b0c0, b=0x7fffd247b190, \r\n    beta=0x7fffd247bf60, c=0x7fffd247b260, cntx=0x7fffd247c190, cntl=0x7fffec002e40, thread=0x7fffb80070c0) at frame/base/bli_threading.c:92\r\n#13 0x0000000000447f5a in bli_gemm_front (alpha=0x7fffd247bcf0, a=0x7fffd247bdc0, b=0x7fffd247be90, beta=0x7fffd247bf60, c=0x7fffd247c030, cntx=0x7fffd247c190, \r\n    cntl=0x7fffec002e40) at frame/3/gemm/bli_gemm_front.c:86\r\n#14 0x0000000000429be5 in bli_gemmnat (alpha=0x7fffd247bcf0, a=0x7fffd247bdc0, b=0x7fffd247be90, beta=0x7fffd247bf60, c=0x7fffd247c030, cntx=0x7fffd247c190)\r\n    at frame/ind/oapi/bli_l3_nat_oapi.c:80\r\n#15 0x000000000049242b in bli_gemmind (alpha=0x7fffd247bcf0, a=0x7fffd247bdc0, b=0x7fffd247be90, beta=0x7fffd247bf60, c=0x7fffd247c030, cntx=0x7fffd247c190)\r\n    at frame/ind/oapi/bli_l3_ind_oapi.c:59\r\n#16 0x000000000044701e in bli_gemm_ex (alpha=0x7fffd247bcf0, a=0x7fffd247bdc0, b=0x7fffd247be90, beta=0x7fffd247bf60, c=0x7fffd247c030, cntx=0x7fffd247c190)\r\n    at frame/3/bli_l3_oapi.c:74\r\n#17 0x0000000000419e3c in bli_sgemm (transa=BLIS_NO_TRANSPOSE, transb=BLIS_NO_TRANSPOSE, m=1936, n=16, k=25, alpha=0x7fffd247c188, a=0x7fffb8091540, rs_a=25, cs_a=1, \r\n    b=0x7fffb8003790, rs_b=16, cs_b=1, beta=0x7fffd247c18c, c=0x7fffb8040e30, rs_c=16, cs_c=1, cntx=0x7fffd247c190) at frame/3/bli_l3_tapi.c:93\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/flame/blis/issues/comments/214927163","html_url":"https://github.com/flame/blis/issues/68#issuecomment-214927163","issue_url":"https://api.github.com/repos/flame/blis/issues/68","id":214927163,"user":{"login":"songmaotian","id":12146033,"avatar_url":"https://avatars.githubusercontent.com/u/12146033?v=3","gravatar_id":"","url":"https://api.github.com/users/songmaotian","html_url":"https://github.com/songmaotian","followers_url":"https://api.github.com/users/songmaotian/followers","following_url":"https://api.github.com/users/songmaotian/following{/other_user}","gists_url":"https://api.github.com/users/songmaotian/gists{/gist_id}","starred_url":"https://api.github.com/users/songmaotian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/songmaotian/subscriptions","organizations_url":"https://api.github.com/users/songmaotian/orgs","repos_url":"https://api.github.com/users/songmaotian/repos","events_url":"https://api.github.com/users/songmaotian/events{/privacy}","received_events_url":"https://api.github.com/users/songmaotian/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T00:17:28Z","updated_at":"2016-04-27T00:17:28Z","body":"@fgvanzee thanks for that, thanks for all your great work, I have been so busy that I have no time to dig deeper, sorry for that"}}