{"action":"created","comment":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/44718015","id":44718015,"diff_hunk":"@@ -12,35 +12,68 @@ cdef np.float64_t magnitude_squared(np.complex64_t z) nogil:\n @cython.boundscheck(False)\n @cython.wraparound(False)\n cpdef mandelbrot(np.complex64_t [:, :] in_coords,\n-                 np.uint32_t [:, :] out_counts,\n+                 np.float32_t [:, :] out_counts,\n                  int max_iterations=511):\n+    #np.uint32_t [:, :] out_counts,\n     cdef:\n        int i, j, iter\n+       int width = in_coords.shape[1]\n+       int height = in_coords.shape[0]\n        np.complex64_t c, z\n-\n-       # To declare AVX.float8 variables, use:\n-       # cdef:\n-       #     AVX.float8 v1, v2, v3\n-       #\n-       # And then, for example, to multiply them\n-       #     v3 = AVX.mul(v1, v2)\n-       #\n-       # You may find the numpy.real() and numpy.imag() fuctions helpful.\n+       AVX.float8 c_r, c_i, real_part, img_part, counter_avx, mask_avx, criteria_avx, increment_avx, z_i, z_r, mask_avx2\n+       float [:, :] real, img\n \n     assert in_coords.shape[1] % 8 == 0, \"Input array must have 8N columns\"\n     assert in_coords.shape[0] == out_counts.shape[0], \"Input and output arrays must be the same size\"\n     assert in_coords.shape[1] == out_counts.shape[1],  \"Input and output arrays must be the same size\"\n \n+    real = numpy.real(in_coords)\n+    img = numpy.imag(in_coords)\n+\n     with nogil:\n-        for i in range(in_coords.shape[0]):\n-            for j in range(in_coords.shape[1]):\n-                c = in_coords[i, j]\n-                z = 0\n+        for i in prange(height, schedule='static', chunksize=1, num_threads=1):\n+            for j in range(width/8):\n+\n+                # segmenting the values into AVX data structure, real and imaginary parts seperately.\n+                z_r = AVX.float_to_float8(0.0)\n+                z_i = AVX.float_to_float8(0.0)\n+                c_r = AVX.make_float8(real[i, j*8],\n+                                           real[i, j*8+1],\n+                                           real[i, j*8+2],\n+                                           real[i, j*8+3],\n+                                           real[i, j*8+4],\n+                                           real[i, j*8+5],\n+                                           real[i, j*8+6],\n+                                           real[i, j*8+7])\n+                c_i = AVX.make_float8(img[i, j*8],\n+                                          img[i, j*8+1],\n+                                          img[i, j*8+2],\n+                                          img[i, j*8+3],\n+                                          img[i, j*8+4],\n+                                          img[i, j*8+5],\n+                                          img[i, j*8+6],\n+                                          img[i, j*8+7])\n+\n+                # initialize counter (intensity) and criteria\n+                counter_avx = AVX.float_to_float8(0)\n+                criteria_avx = AVX.float_to_float8(4)\n+\n+                # Do Mandelbrot fractal...\n                 for iter in range(max_iterations):\n-                    if magnitude_squared(z) > 4:\n+\n+                    real_part = AVX.add(AVX.sub(AVX.mul(z_r, z_r), AVX.mul(z_i, z_i)), c_r)\n+                    img_part = AVX.add(AVX.mul(AVX.mul(z_r, z_i), AVX.float_to_float8(2)), c_i)\n+                    mask_avx = AVX.less_than(AVX.add(AVX.mul(real_part, real_part), AVX.mul(img_part, img_part)), \n+                                            AVX.float_to_float8(4))","path":"HW2/P3/mandelbrot.pyx","position":71,"original_position":71,"commit_id":"4db29f94190931a9a5ba5d33739a72dac8d831cf","original_commit_id":"4db29f94190931a9a5ba5d33739a72dac8d831cf","user":{"login":"dekatzenel","id":4731168,"avatar_url":"https://avatars.githubusercontent.com/u/4731168?v=3","gravatar_id":"","url":"https://api.github.com/users/dekatzenel","html_url":"https://github.com/dekatzenel","followers_url":"https://api.github.com/users/dekatzenel/followers","following_url":"https://api.github.com/users/dekatzenel/following{/other_user}","gists_url":"https://api.github.com/users/dekatzenel/gists{/gist_id}","starred_url":"https://api.github.com/users/dekatzenel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekatzenel/subscriptions","organizations_url":"https://api.github.com/users/dekatzenel/orgs","repos_url":"https://api.github.com/users/dekatzenel/repos","events_url":"https://api.github.com/users/dekatzenel/events{/privacy}","received_events_url":"https://api.github.com/users/dekatzenel/received_events","type":"User","site_admin":false},"body":"You've squished so many operations into 3 lines of code that it becomes hard to read. Comments and/or more lines would have been useful.","created_at":"2015-11-12T21:35:01Z","updated_at":"2015-11-12T21:35:01Z","html_url":"https://github.com/harvard-cs205/cs205-homework/pull/316#discussion_r44718015","pull_request_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316","_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments/44718015"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/316#discussion_r44718015"},"pull_request":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316"}}},"pull_request":{"url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316","id":49580069,"html_url":"https://github.com/harvard-cs205/cs205-homework/pull/316","diff_url":"https://github.com/harvard-cs205/cs205-homework/pull/316.diff","patch_url":"https://github.com/harvard-cs205/cs205-homework/pull/316.patch","issue_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/316","number":316,"state":"open","locked":false,"title":"Hw2","user":{"login":"haosutang","id":14118456,"avatar_url":"https://avatars.githubusercontent.com/u/14118456?v=3","gravatar_id":"","url":"https://api.github.com/users/haosutang","html_url":"https://github.com/haosutang","followers_url":"https://api.github.com/users/haosutang/followers","following_url":"https://api.github.com/users/haosutang/following{/other_user}","gists_url":"https://api.github.com/users/haosutang/gists{/gist_id}","starred_url":"https://api.github.com/users/haosutang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haosutang/subscriptions","organizations_url":"https://api.github.com/users/haosutang/orgs","repos_url":"https://api.github.com/users/haosutang/repos","events_url":"https://api.github.com/users/haosutang/events{/privacy}","received_events_url":"https://api.github.com/users/haosutang/received_events","type":"User","site_admin":false},"body":"Homework 2 is quite self-contained and helped me in thinking in parallel and I learned ways to implement multithreading, locking, events handling, SIMD, and improving algorithm.","created_at":"2015-11-03T16:47:08Z","updated_at":"2015-11-12T21:35:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5e2f966e5844cd9244b808b6d477e54ba581693","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316/commits","review_comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316/comments","review_comment_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/316/comments","statuses_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/4db29f94190931a9a5ba5d33739a72dac8d831cf","head":{"label":"haosutang:HW2","ref":"HW2","sha":"4db29f94190931a9a5ba5d33739a72dac8d831cf","user":{"login":"haosutang","id":14118456,"avatar_url":"https://avatars.githubusercontent.com/u/14118456?v=3","gravatar_id":"","url":"https://api.github.com/users/haosutang","html_url":"https://github.com/haosutang","followers_url":"https://api.github.com/users/haosutang/followers","following_url":"https://api.github.com/users/haosutang/following{/other_user}","gists_url":"https://api.github.com/users/haosutang/gists{/gist_id}","starred_url":"https://api.github.com/users/haosutang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haosutang/subscriptions","organizations_url":"https://api.github.com/users/haosutang/orgs","repos_url":"https://api.github.com/users/haosutang/repos","events_url":"https://api.github.com/users/haosutang/events{/privacy}","received_events_url":"https://api.github.com/users/haosutang/received_events","type":"User","site_admin":false},"repo":{"id":41985286,"name":"cs205-homework","full_name":"haosutang/cs205-homework","owner":{"login":"haosutang","id":14118456,"avatar_url":"https://avatars.githubusercontent.com/u/14118456?v=3","gravatar_id":"","url":"https://api.github.com/users/haosutang","html_url":"https://github.com/haosutang","followers_url":"https://api.github.com/users/haosutang/followers","following_url":"https://api.github.com/users/haosutang/following{/other_user}","gists_url":"https://api.github.com/users/haosutang/gists{/gist_id}","starred_url":"https://api.github.com/users/haosutang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haosutang/subscriptions","organizations_url":"https://api.github.com/users/haosutang/orgs","repos_url":"https://api.github.com/users/haosutang/repos","events_url":"https://api.github.com/users/haosutang/events{/privacy}","received_events_url":"https://api.github.com/users/haosutang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haosutang/cs205-homework","description":"","fork":true,"url":"https://api.github.com/repos/haosutang/cs205-homework","forks_url":"https://api.github.com/repos/haosutang/cs205-homework/forks","keys_url":"https://api.github.com/repos/haosutang/cs205-homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haosutang/cs205-homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haosutang/cs205-homework/teams","hooks_url":"https://api.github.com/repos/haosutang/cs205-homework/hooks","issue_events_url":"https://api.github.com/repos/haosutang/cs205-homework/issues/events{/number}","events_url":"https://api.github.com/repos/haosutang/cs205-homework/events","assignees_url":"https://api.github.com/repos/haosutang/cs205-homework/assignees{/user}","branches_url":"https://api.github.com/repos/haosutang/cs205-homework/branches{/branch}","tags_url":"https://api.github.com/repos/haosutang/cs205-homework/tags","blobs_url":"https://api.github.com/repos/haosutang/cs205-homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haosutang/cs205-homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haosutang/cs205-homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/haosutang/cs205-homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haosutang/cs205-homework/statuses/{sha}","languages_url":"https://api.github.com/repos/haosutang/cs205-homework/languages","stargazers_url":"https://api.github.com/repos/haosutang/cs205-homework/stargazers","contributors_url":"https://api.github.com/repos/haosutang/cs205-homework/contributors","subscribers_url":"https://api.github.com/repos/haosutang/cs205-homework/subscribers","subscription_url":"https://api.github.com/repos/haosutang/cs205-homework/subscription","commits_url":"https://api.github.com/repos/haosutang/cs205-homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/haosutang/cs205-homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/haosutang/cs205-homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/haosutang/cs205-homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/haosutang/cs205-homework/contents/{+path}","compare_url":"https://api.github.com/repos/haosutang/cs205-homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haosutang/cs205-homework/merges","archive_url":"https://api.github.com/repos/haosutang/cs205-homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haosutang/cs205-homework/downloads","issues_url":"https://api.github.com/repos/haosutang/cs205-homework/issues{/number}","pulls_url":"https://api.github.com/repos/haosutang/cs205-homework/pulls{/number}","milestones_url":"https://api.github.com/repos/haosutang/cs205-homework/milestones{/number}","notifications_url":"https://api.github.com/repos/haosutang/cs205-homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haosutang/cs205-homework/labels{/name}","releases_url":"https://api.github.com/repos/haosutang/cs205-homework/releases{/id}","created_at":"2015-09-06T03:21:24Z","updated_at":"2015-09-06T03:21:25Z","pushed_at":"2015-11-03T16:38:22Z","git_url":"git://github.com/haosutang/cs205-homework.git","ssh_url":"git@github.com:haosutang/cs205-homework.git","clone_url":"https://github.com/haosutang/cs205-homework.git","svn_url":"https://github.com/haosutang/cs205-homework","homepage":null,"size":3915,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"harvard-cs205:master","ref":"master","sha":"ed6f0167fd1f6097ce9e454c2950c5db00a0c513","user":{"login":"harvard-cs205","id":13456002,"avatar_url":"https://avatars.githubusercontent.com/u/13456002?v=3","gravatar_id":"","url":"https://api.github.com/users/harvard-cs205","html_url":"https://github.com/harvard-cs205","followers_url":"https://api.github.com/users/harvard-cs205/followers","following_url":"https://api.github.com/users/harvard-cs205/following{/other_user}","gists_url":"https://api.github.com/users/harvard-cs205/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-cs205/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-cs205/subscriptions","organizations_url":"https://api.github.com/users/harvard-cs205/orgs","repos_url":"https://api.github.com/users/harvard-cs205/repos","events_url":"https://api.github.com/users/harvard-cs205/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-cs205/received_events","type":"Organization","site_admin":false},"repo":{"id":40614104,"name":"cs205-homework","full_name":"harvard-cs205/cs205-homework","owner":{"login":"harvard-cs205","id":13456002,"avatar_url":"https://avatars.githubusercontent.com/u/13456002?v=3","gravatar_id":"","url":"https://api.github.com/users/harvard-cs205","html_url":"https://github.com/harvard-cs205","followers_url":"https://api.github.com/users/harvard-cs205/followers","following_url":"https://api.github.com/users/harvard-cs205/following{/other_user}","gists_url":"https://api.github.com/users/harvard-cs205/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-cs205/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-cs205/subscriptions","organizations_url":"https://api.github.com/users/harvard-cs205/orgs","repos_url":"https://api.github.com/users/harvard-cs205/repos","events_url":"https://api.github.com/users/harvard-cs205/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-cs205/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/harvard-cs205/cs205-homework","description":"","fork":false,"url":"https://api.github.com/repos/harvard-cs205/cs205-homework","forks_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/forks","keys_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/teams","hooks_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/hooks","issue_events_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/events{/number}","events_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/events","assignees_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/assignees{/user}","branches_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/branches{/branch}","tags_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/tags","blobs_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/{sha}","languages_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/languages","stargazers_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/stargazers","contributors_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/contributors","subscribers_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/subscribers","subscription_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/subscription","commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/contents/{+path}","compare_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/merges","archive_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/downloads","issues_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues{/number}","pulls_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls{/number}","milestones_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/milestones{/number}","notifications_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/labels{/name}","releases_url":"https://api.github.com/repos/harvard-cs205/cs205-homework/releases{/id}","created_at":"2015-08-12T17:18:15Z","updated_at":"2015-10-21T19:21:28Z","pushed_at":"2015-11-12T15:02:55Z","git_url":"git://github.com/harvard-cs205/cs205-homework.git","ssh_url":"git@github.com:harvard-cs205/cs205-homework.git","clone_url":"https://github.com/harvard-cs205/cs205-homework.git","svn_url":"https://github.com/harvard-cs205/cs205-homework","homepage":null,"size":162893,"stargazers_count":5,"watchers_count":5,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":99,"mirror_url":null,"open_issues_count":348,"forks":99,"open_issues":348,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316"},"html":{"href":"https://github.com/harvard-cs205/cs205-homework/pull/316"},"issue":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/316"},"comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/issues/316/comments"},"review_comments":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316/comments"},"review_comment":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/pulls/316/commits"},"statuses":{"href":"https://api.github.com/repos/harvard-cs205/cs205-homework/statuses/4db29f94190931a9a5ba5d33739a72dac8d831cf"}}}}