64bit integer 를 가장 빠르게 나눌수 있는 방법은..?

Testors의 이미지

32bit machine 에서 __int64 를 어떤 상수(10000 and 100000) 으로 나누어야 할 일이 생겼습니다.
그런데 이것의 성능이 매우 중요한지라, CRT 의 나누기를 쓰면 안됩니다. -- 무려 10배가 느려지더군요 --
MMX와 SSE 를 찾아 보았는데 64,128bit divide instruction 은 float 용만 제공하는것 같군요.
혹시 COOL 한 방법 알고 계신분?

aero의 이미지

정수형 계산을 빠르게 하는 테그닉으로는
Fixed-point Arithmetic 이란걸 쓰지 않나요?

google에서 위 검색어로 찾아보면 관련 정보가 많이 나옵니다.

Testors의 이미지

aero wrote:
정수형 계산을 빠르게 하는 테그닉으로는
Fixed-point Arithmetic 이란걸 쓰지 않나요?

google에서 위 검색어로 찾아보면 관련 정보가 많이 나옵니다.

그건 부동소수점 연산을 할때 정밀도를 약간 희생하고서라도 정수형으로 변환해서 부동소수점에 비해 상대적으로 빠른 정수형 연산을 이용하는..
그러니까 정수형 계산을 빠르게 하는 테크닉이 아니라 부동소수점 연산을 빠르게 하는 테크닉.. 으로 보입니다만... ;

제 질문은 32bit processor 에서 int64 는 divide instruction 이 제공되지 않는데, - MMX 나 SSE 등에서도 -
이걸 CRT 의 것보다 빨리 할수 있는 방법은 없을까.. 입니다.
가령 divisor 가 변하지 않는다는것을 이용한다던가... 해서 말이지요.

ironiris의 이미지

나누려는 상수가 그리 크지 않다면 쉬프트 연산으로 해결하는 방법은 어떨런지요?
3으로 나눈다면 1칸 쉬프트하고 한번 빼는 방식으로요..
10으로 나눈다면 3칸 쉬프트하고 두번 빼구요. --;
아무것도 모르지만 그냥 주절거려봤습니다. :)
정식교육도 받은 적이 없지만.. 혹시나...

Testors의 이미지

자답입니다.

역시 divisor 가 상수라는걸 이용한 트릭이 있었네요.

divide by constant 로 검색하면 이런게 나오더군요.

응용하면 64bit 에서도 쓸수 있을듯 합니다.

http://www.dpgraph.com/assembly.html#tips-and-tricks-divide-by-a-constant

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.