{"action":"created","issue":{"url":"https://api.github.com/repos/pg-strom/devel/issues/118","labels_url":"https://api.github.com/repos/pg-strom/devel/issues/118/labels{/name}","comments_url":"https://api.github.com/repos/pg-strom/devel/issues/118/comments","events_url":"https://api.github.com/repos/pg-strom/devel/issues/118/events","html_url":"https://github.com/pg-strom/devel/issues/118","id":55861327,"number":118,"title":"(JP) numericデータ型をキーとしたGpuHashJoinでOpenCL execution error (build program failure)","user":{"login":"onlyindreams","id":7244786,"avatar_url":"https://avatars.githubusercontent.com/u/7244786?v=3","gravatar_id":"","url":"https://api.github.com/users/onlyindreams","html_url":"https://github.com/onlyindreams","followers_url":"https://api.github.com/users/onlyindreams/followers","following_url":"https://api.github.com/users/onlyindreams/following{/other_user}","gists_url":"https://api.github.com/users/onlyindreams/gists{/gist_id}","starred_url":"https://api.github.com/users/onlyindreams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onlyindreams/subscriptions","organizations_url":"https://api.github.com/users/onlyindreams/orgs","repos_url":"https://api.github.com/users/onlyindreams/repos","events_url":"https://api.github.com/users/onlyindreams/events{/privacy}","received_events_url":"https://api.github.com/users/onlyindreams/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-29T06:23:34Z","updated_at":"2015-01-29T10:02:25Z","closed_at":null,"body":"numericデータ型をキーとしてGpuHashJoinで OpenCL execution errorが発生しました。\r\n\r\n再現クエリ\r\n```\r\nset enable_seqscan to off;\r\nset enable_bitmapscan to off;\r\nset enable_indexscan to off;\r\nset random_page_cost=1000000;   --# force off index_scan.\r\nset enable_gpuhashjoin to on;\r\nset enable_gpupreagg to off;\r\nset enable_mergejoin to off;\r\nset enable_nestloop to off;\r\nset client_min_messages to warning;\r\n\r\nset pg_strom.enabled=on;\r\nset enable_hashjoin to off;\r\n\r\ndrop table if exists orz2;\r\ncreate table orz2 as select 1::numeric as nume;\r\nexplain select * from orz2 a inner join orz2 b on a.nume=b.nume;\r\nselect * from orz2 a inner join orz2 b on a.nume=b.nume;\r\n```\r\n\r\nエラー内容\r\n```\r\nERROR:  PG-Strom: OpenCL execution error (build program failure)\r\nSTROMCL_VARLENA_HASHKEY_TEMPLATE(numeric)\r\nSTROMCL_VARLENA_HASHREF_TEMPLATE(numeric)\r\nSTROMCL_SIMPLE_HASHKEY_TEMPLATE(bool,cl_bool)\r\nSTROMCL_SIMPLE_HASHREF_TEMPLATE(bool,cl_bool)\r\n\r\nstatic cl_uint\r\ngpuhashjoin_execute(__private cl_int *errcode,\r\n                    __global kern_parambuf *kparams,\r\n                    __global kern_multihash *kmhash,\r\n                    __local cl_uint *pg_crc32_table,\r\n                    __global kern_data_store *kds,\r\n                    __global kern_data_store *ktoast,\r\n                    size_t kds_index,\r\n                    __global cl_int *rbuffer)\r\n{\r\n__global kern_hashtable *khtable_1 = KERN_HASHTABLE(kmhash,1);\r\n__global kern_hashentry *kentry_1;\r\npg_numeric_t KVAR_1 = pg_numeric_vref(kds,ktoast,errcode,0,kds_index);\r\ncl_int n_matches = 0;\r\ncl_uint hash_1;\r\n\r\nINIT_CRC32C(hash_1);\r\nhash_1 = pg_numeric_hashkey(pg_crc32_table, hash_1, KVAR_1);\r\nFIN_CRC32C(hash_1);\r\nfor (kentry_1 = KERN_HASH_FIRST_ENTRY(khtable_1, hash_1);\r\n     kentry_1 != NULL;\r\n     kentry_1 = KERN_HASH_NEXT_ENTRY(khtable_1, kentry_1))\r\n{\r\npg_numeric_t KVAR_2 = pg_numeric_hashref(khtable_1,kentry_1,errcode,0);\r\nif (EQ_CRC32C(kentry_1->hash, hash_1) &&\r\n    EVAL(pgfn_numeric_eq(errcode, KVAR_1, KVAR_2)))\r\n{\r\nn_matches++;\r\nif (rbuffer)\r\n{\r\n  rbuffer[0] = (cl_int)kds_index + 1;\r\n  rbuffer[1] = (cl_int)((uintptr_t)kentry_1 - (uintptr_t)khtable_1);\r\n  rbuffer += 2;\r\n}\r\n}\r\n}\r\nreturn n_matches;\r\n}\r\n\r\nstatic void\r\ngpuhashjoin_projection_mapping(cl_int dest_colidx,\r\n                               __private cl_uint *src_depth,\r\n                               __private cl_uint *src_colidx)\r\n{\r\n  switch (dest_colidx)\r\n  {\r\n  case 0:\r\n    *src_depth = 0;\r\n    *src_colidx = 0;\r\n    break;\r\n  case 1:\r\n    *src_depth = 1;\r\n    *src_colidx = 0;\r\n    break;\r\n  default:\r\n    /* should not run here */\r\n    break;\r\n  }\r\n}\r\n\r\nstatic void\r\ngpuhashjoin_projection_datum(__private cl_int *errcode,\r\n                             __global Datum *slot_values,\r\n                             __global cl_char *slot_isnull,\r\n                             cl_int depth,\r\n                             cl_int colidx,\r\n                             hostptr_t hostaddr,\r\n                             __global void *datum)\r\n{\r\n  switch (depth)\r\n  {\r\n  case 0:\r\n    switch (colidx)\r\n    {\r\n    case 0:\r\n      if (!datum)\r\n        slot_isnull[0] = (cl_char) 1;\r\n      else\r\n      {\r\n        slot_isnull[0] = (cl_char) 0;\r\n        slot_values[0] = (Datum) hostaddr;\r\n      }\r\n      break;\r\n    default: /* do nothing */ break;\r\n    }\r\n    break;\r\n  case 1:\r\n    switch (colidx)\r\n    {\r\n    case 0:\r\n      if (!datum)\r\n        slot_isnull[1] = (cl_char) 1;\r\n      else\r\n      {\r\n        slot_isnull[1] = (cl_char) 0;\r\n        slot_values[1] = (Datum) hostaddr;\r\n      }\r\n      break;\r\n    default: /* do nothing */ break;\r\n    }\r\n    break;\r\n  default: /* do nothing */ break;\r\n  }\r\n}\r\nstatic bool\r\ngpuhashjoin_qual_eval(__private cl_int *errcode,\r\n                      __global kern_parambuf *kparams,\r\n                      __global kern_data_store *kds,\r\n                      __global kern_data_store *ktoast,\r\n                      size_t kds_index)\r\n{\r\n  return true;\r\n}\r\n\r\nDETAIL:  :3837:1: error: returning 'pg_varlena_t' from a function with incompatible result type 'pg_numeric_t'; \r\nSTROMCL_VARLENA_HASHREF_TEMPLATE(numeric)\r\n^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n:3746:10: note: expanded from:\r\n                return pg_varlena_hashref(khtable, kentry,                      \\\r\n                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n```\r\n\r\n可変長データ型をキーにするともれなくエラーが発生するのかと思いましたが、テキスト型ではエラーは発生しませんでした。\r\n\r\n```\r\ncontrib_regression=# explain select * from orz a inner join orz b on a.tex=b.tex;\r\n                                      QUERY PLAN                                      \r\n--------------------------------------------------------------------------------------\r\n Custom Scan (GpuHashJoin)  (cost=1539.47..1650.55 rows=8580 width=64)\r\n   Hash clause 1: (tex = tex)\r\n   Bulkload: On\r\n   ->  Custom Scan (GpuScan) on orz a  (cost=500.00..523.10 rows=1310 width=32)\r\n   ->  Custom Scan (MultiHash)  (cost=523.10..523.10 rows=1310 width=32)\r\n         hash keys: tex\r\n         nBatches: 1  Buckets: 1506  Memory Usage: 99.10%\r\n         ->  Custom Scan (GpuScan) on orz b  (cost=500.00..523.10 rows=1310 width=32)\r\n(8 rows)\r\n\r\ncontrib_regression=# select * from orz a inner join orz b on a.tex=b.tex;\r\n tex | tex \r\n-----+-----\r\n 1   | 1\r\n(1 row)\r\n```"},"comment":{"url":"https://api.github.com/repos/pg-strom/devel/issues/comments/71998324","html_url":"https://github.com/pg-strom/devel/issues/118#issuecomment-71998324","issue_url":"https://api.github.com/repos/pg-strom/devel/issues/118","id":71998324,"user":{"login":"kaigai","id":216210,"avatar_url":"https://avatars.githubusercontent.com/u/216210?v=3","gravatar_id":"","url":"https://api.github.com/users/kaigai","html_url":"https://github.com/kaigai","followers_url":"https://api.github.com/users/kaigai/followers","following_url":"https://api.github.com/users/kaigai/following{/other_user}","gists_url":"https://api.github.com/users/kaigai/gists{/gist_id}","starred_url":"https://api.github.com/users/kaigai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaigai/subscriptions","organizations_url":"https://api.github.com/users/kaigai/orgs","repos_url":"https://api.github.com/users/kaigai/repos","events_url":"https://api.github.com/users/kaigai/events{/privacy}","received_events_url":"https://api.github.com/users/kaigai/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T10:02:25Z","updated_at":"2015-01-29T10:02:25Z","body":"6acdcf57fe1fe9ef97bb70c9ce5ab2727805b20a ですね。\r\nGpuHashJoinに固有だったCRC32(HASH値)計算のロジックを、GpuPreAggと共有するよう修正した時にまとめて入れています。が、numeric側の修正は見落としていてその後のどこかのタイミングですな…。"}}