KR101752062B1 - Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units - Google Patents

Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units Download PDF

Info

Publication number
KR101752062B1
KR101752062B1 KR1020150144800A KR20150144800A KR101752062B1 KR 101752062 B1 KR101752062 B1 KR 101752062B1 KR 1020150144800 A KR1020150144800 A KR 1020150144800A KR 20150144800 A KR20150144800 A KR 20150144800A KR 101752062 B1 KR101752062 B1 KR 101752062B1
Authority
KR
South Korea
Prior art keywords
thread
data
threads
reuse
identified
Prior art date
Application number
KR1020150144800A
Other languages
Korean (ko)
Other versions
KR20170045437A (en
Inventor
한환수
김현준
고요한
Original Assignee
성균관대학교산학협력단
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 성균관대학교산학협력단 filed Critical 성균관대학교산학협력단
Priority to KR1020150144800A priority Critical patent/KR101752062B1/en
Publication of KR20170045437A publication Critical patent/KR20170045437A/en
Application granted granted Critical
Publication of KR101752062B1 publication Critical patent/KR101752062B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0875Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with dedicated cache, e.g. instruction or stack
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3004Arrangements for executing specific machine instructions to perform operations on memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3808Instruction prefetching for instruction reuse, e.g. trace cache, branch target cache

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

본 발명의 실시예들에 따른 컴퓨터를 이용하여 그래픽 프로세서 상에서 범용 어플리케이션의 구동을 분석하는 범용 어플리케이션 분석 방법은 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계, 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 단계 및 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 단계를 포함할 수 있다.A general-purpose application analysis method for analyzing the operation of a general-purpose application on a graphic processor using a computer according to embodiments of the present invention includes monitoring a global memory access of a general-purpose application before optimization executed on a graphics processor emulator, The method comprising: generating a memory access record by recording thread information and a data index of a thread; when a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a thread belonging to each thread group is accessed A plurality of data groups in which at least one data grouping is clustered in the order in which the plurality of data groups are clustered, creating a reuse stack for each thread group, and analyzing a reuse pattern of the data groups based on the reuse stack .

Description

범용 어플리케이션을 그래픽 프로세서에서 구동하기 위한 범용 어플리케이션 분석 장치 및 분석 방법{APPARATUS AND METHOD FOR ANALYZING GENERAL APPLICATION TO BE OPERATIVE UPON GENERAL-PURPOSE GRAPHIC PROCESSING UNITS}TECHNICAL FIELD [0001] The present invention relates to a general-purpose application analyzing apparatus and an analyzing method for driving a general-purpose application on a graphic processor. [0002] Generally,

본 발명은 그래픽 프로세서 상의 범용 컴퓨팅 기술(General-purpose computing on Graphic Processing Units)에 관한 것으로, 더욱 상세하게는, 그래픽 프로세서 상에서 범용 어플리케이션을 구동하는 기술에 관한 것이다.The present invention relates to general-purpose computing on graphic processing units, and more particularly, to a technique for driving a general-purpose application on a graphics processor.

전통적으로 그래픽 프로세서는 컴퓨터 그래픽용 연산을 위한 제한적 기능을 가졌지만, 3D 그래픽 렌더링이 그래픽 프로세서의 주요 기능으로 자리잡게 되고 프로그래밍 가능한 꼭지점 셰이더와 프래그먼트 셰이더가 채택되면서, 프로그래머가 프로그램하기에 따라 다양한 창의적인 그래픽 효과를 구현할 수 있게 되었다.Traditionally, graphics processors have limited functionality for computational calculations, but 3D graphics rendering has become a major feature of graphics processors, and programmable vertex shaders and fragment shaders have been adopted, allowing programmers to program various creative graphics Effect can be implemented.

그래픽 프로세서 제조사들의 치열한 경쟁에 따라 그래픽 프로세서 내에 집적되는 셰이더의 수와 속도가 급증하면서, 그래픽 렌더링이 아닌 다른 목적의 병렬 연산 어플리케이션도 그래픽 프로세서를 통해 고속으로 처리할 가능성이 열렸는데, 이를 GPGPU(General-purpose computing on Graphic Processing Units)라 한다.Due to the intense competition of graphics processor manufacturers, the number and speed of shaders accumulated in the graphics processor has increased rapidly, and parallel computing applications other than graphics rendering have been opened up to high speed processing through the graphics processor. - computing on Graphic Processing Units).

GPGPU 개념이 등장하던 초기에는 프로그래머가 그래픽 프로세서에서 처리하려는 어플리케이션의 병렬성과 그래픽 프로세서의 하드웨어 특성에 관하여 깊이 이해하고 있지 않으면 어플리케이션을 범용 프로세서인 CPU에서 구현하는 것보다 장점이 없었다. 하지만, 프로그래머가 C 언어와 같은 친숙한 범용 언어로 병렬 연산 어플리케이션을 프로그래밍할 수 있도록 보조하는 CUDA 또는 OpenCL과 같은 GPGPU 프로그래밍 모델들이 등장하면서, GPGPU는 점점 대중화되고 있다.In the early days of the GPGPU concept, programmers had no advantage over implementing the application on a general-purpose CPU, unless the programmer had a deep understanding of the parallelism of the application and the hardware characteristics of the graphics processor. However, as GPGPU programming models such as CUDA or OpenCL, which help programmers to program parallel computing applications in a familiar, general-purpose language such as the C language, GPGPU is becoming more and more popular.

비록 CUDA와 같은 프로그래밍 모델에 의해 GPGPU 프로그래밍이 편리해지기는 했지만, GPU는 본질적으로 3D 그래픽 처리에 특화되어 있기 때문에 스트리밍 프로세싱(streaming processing)을 이용하여 처리할 수 있는 문제에 적합하다. GPU는 수많은 스트리밍 프로세서들을 가지고 있고 스트리밍 프로세서들은 각각 예를 들어, 텍스처를 읽고 비트맵 변환 연산하고 연산 결과를 프레임 버퍼에 쓰는 동작을 병렬적으로, 독립적으로 처리하기 때문에, GPU에서는 공유되는 데이터 또는 정적 데이터는 원칙적으로 필요하지 않다고 알려져 있다.Although GPU programming is made easier by programming models such as CUDA, GPUs are inherently specialized in 3D graphics processing, making them suitable for problems that can be handled using streaming processing. Because GPUs have many streaming processors and each streaming processor, for example, reads textures, performs bitmap conversion operations, and writes the results of operations to the frame buffer in parallel, independently, the GPU handles shared data or static It is known that data is not required in principle.

반면에 범용 어플리케이션은 통상적으로 쓰레드들 간에 공유되는 데이터들을 다수 포함한다. 범용 어플리케이션을 GPU에서 구동시키기 위해서는 이러한 공유 데이터들, 전역적 데이터들 또는 정적 데이터들의 저장을 담당할 하드웨어가 필요하다. 이에 따라, 최신의 GPGPU 지원 GPU들은 프로그래머가 전역적으로 사용할 수 있는 공유 메모리를 가지고 있다. 프로그래머는 공유 메모리를 통해 쓰레드 간에 데이터의 공유를 구현하고 시스템 메모리로부터 데이터를 가져오는 데에 걸리는 지연 시간도 줄일 수 있다.On the other hand, a general-purpose application typically includes a large number of data shared among threads. To run a general-purpose application on the GPU, hardware is needed to store these shared data, global data, or static data. As a result, the latest GPU GPU-enabled GPUs have shared memory that programmers can use globally. Programmers can also share data between threads through shared memory and reduce the latency of fetching data from system memory.

하지만 공유 메모리의 사용이 언제나 성능 향상을 가져오는 것은 아니다. 먼저, 공유 메모리는 크기가 작기 때문에 큰 데이터를 저장하기 어렵다. 또한 공유 메모리는 물리적으로 여러 뱅크들로 이루어지는데, 각 뱅크에는 한 번에 하나의 쓰레드만 접근할 수 있기 때문에 만약 여러 쓰레드들이 한 뱅크에 동시에 접근하려 하면 오히려 상당한 시간 지연을 초래하는 뱅크 충돌 현상이 일어날 수 있다.However, the use of shared memory does not always improve performance. First, since shared memory is small in size, it is difficult to store large data. In addition, shared memory is physically composed of several banks, each of which can access only one thread at a time. Therefore, if several threads try to access a bank at the same time, a bank collision phenomenon Can happen.

또한, GPGPU 프로세서는 원래 기능인 그래픽 연산을 위해 최적화되어 있기 때문에, 프로그래머는 범용 어플리케이션을 잘 작성하기 위해서는 특정 GPGPU의 하드웨어 아키텍처, 특정 어플리케이션의 병렬성, 특정 어플리케이션의 구동 시에 특정 CPU와 특정 GPU의 협업 관계 등에 관하여 깊게 이해하여야 하고, 그러한 깊은 이해에 기초하여 특정 범용 어플리케이션마다 특정 GPGPU에 적합한 최적화 규칙을 찾고 어플리케이션을 코딩해야 하는 문제는 여전하다.In addition, since the GPGPU processor is optimized for graphic operation, which is the original function, the programmer must know the hardware architecture of a specific GPGPU, the parallelism of a specific application, the cooperation relationship between a specific CPU and a specific GPU Etc., and it is still a problem to find an optimization rule suitable for a specific GPGPU for each general-purpose application based on such a deep understanding and to code the application.

본 발명이 해결하고자 하는 과제는 범용 어플리케이션을 그래픽 프로세서에서 구동하기 위한 범용 어플리케이션 분석 장치 및 분석 방법을 제공하는 데에 있다.SUMMARY OF THE INVENTION It is an object of the present invention to provide a general-purpose application analysis apparatus and an analysis method for driving a general-purpose application in a graphics processor.

본 발명이 해결하고자 하는 과제는 범용 어플리케이션을 그래픽 프로세서에서 구동하기 위해, 어플리케이션의 메모리 접근 패턴을 분석하고 프로파일링하여 실행 시에 재사용되는 데이터를 식별하는 범용 어플리케이션 분석 장치 및 분석 방법을 제공하는 데에 있다.SUMMARY OF THE INVENTION The present invention provides a general-purpose application analyzing apparatus and an analyzing method for analyzing and accessing a memory access pattern of an application in order to drive a general-purpose application in a graphic processor, thereby identifying data to be reused at the time of execution have.

본 발명이 해결하고자 하는 과제는 범용 어플리케이션을 그래픽 프로세서에서 구동하기 위해, 실행 시에 재사용되는 것으로 식별된 데이터에 관하여, 이러한 데이터들이 GPGPU의 공유 메모리에 캐싱되도록 만드는 코드를 범용 어플리케이션의 소스 코드 내에 자동으로 삽입함으로써, 범용 어플리케이션을 GPGPU의 메모리 아키텍처에 최적화하는 범용 어플리케이션 분석 장치 및 분석 방법을 제공하는 데에 있다.SUMMARY OF THE INVENTION It is an object of the present invention to provide a method and system for automatically generating, in a graphics processor, a code for causing a general-purpose application to be cached in a GPGPU shared memory with respect to data identified as being re- To thereby provide a general-purpose application analyzing apparatus and method for optimizing a general-purpose application to the memory architecture of the GPGPU.

본 발명의 해결과제는 이상에서 언급된 것들에 한정되지 않으며, 언급되지 아니한 다른 해결과제들은 아래의 기재로부터 당업자에게 명확히 이해될 수 있을 것이다.The solution to the problem of the present invention is not limited to those mentioned above, and other solutions not mentioned can be clearly understood by those skilled in the art from the following description.

본 발명의 일 측면에 따라 컴퓨터를 이용하여 그래픽 프로세서 상에서 범용 어플리케이션의 구동을 분석하는 범용 어플리케이션 분석 방법은, 상기 컴퓨터가, 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역(global) 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계; 상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 단계; 및 상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 단계를 포함할 수 있다.According to an aspect of the present invention, there is provided a general-purpose application analysis method for analyzing the operation of a general-purpose application on a graphics processor using a computer, the method comprising: monitoring Generating a memory access record by recording thread information and a data index of a thread causing a global memory access; When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, Creating a reuse stack for each thread group; And analyzing a reuse pattern of data groups based on the reuse stack.

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함할 수 있다.According to one embodiment, analyzing the reuse pattern may include calculating reuse distance of each of the data groups that are accessed more than once by threads belonging to the thread group, based on the reuse stack, for each thread group Step < / RTI >

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의될 수 있다.According to one embodiment, analyzing the reuse pattern comprises calculating thread density for each thread group, based on the memory access record and the reuse stack of the thread group, wherein the thread density is a global The ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing the memory access.

일 실시예에 따라, 상기 쓰레드 그룹은 커널이고, 상기 메모리 접근 기록은 커널 정보, 쓰레드 정보 및 데이터 인덱스를 포함하도록 생성될 수 있다.According to one embodiment, the thread group is a kernel, and the memory access record may be generated to include kernel information, thread information, and a data index.

본 발명의 다른 측면에 따라, 컴퓨터를 이용하여 공유 메모리를 가지는 그래픽 프로세서 상에서 범용 어플리케이션의 소스 코드를 최적화하는 범용 어플리케이션 최적화 방법은 상기 컴퓨터가, 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계; 상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 단계; 상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 단계; 및 상기 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터에 관하여, 상기 데이터를 상기 공유 메모리에 저장하는 코드를 가지도록 상기 범용 어플리케이션의 소스 코드를 수정하는 단계를 포함할 수 있다.According to another aspect of the present invention there is provided a general application optimization method for optimizing source code of a general purpose application on a graphics processor having a shared memory using a computer, Generating a memory access record by recording thread information and a data index of a thread causing a global memory access; When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, Creating a reuse stack for each thread group; Analyzing a reuse pattern of data groups based on the reuse stack; And modifying the source code of the general purpose application to have code for storing the data in the shared memory with respect to data identified as being reused based on the reuse pattern.

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함하고, 상기 범용 어플리케이션의 소스 코드를 수정하는 단계는 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계; 및 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함할 수 있다.According to one embodiment, analyzing the reuse pattern may include calculating reuse distance of each of the data groups that are accessed more than once by threads belonging to the thread group, based on the reuse stack, for each thread group Wherein the step of modifying the source code of the general purpose application comprises: identifying a reuse thread and reused data, respectively, based on the reuse distance; And for the identified thread and data, a statement for storing the reused data in the shared memory after the start of the identified thread, and for executing the identified thread while the identified thread is executing the identified data in the shared memory And modifying the source code so as to have a syntax to access from the source code.

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 범용 어플리케이션의 소스 코드를 수정하는 단계는 상기 쓰레드 밀도가 소정의 문턱값 예를 들어 1보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및 상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 전에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함할 수 있다.According to one embodiment, analyzing the reuse pattern comprises calculating thread density for each thread group, based on the memory access record and the reuse stack of the thread group, wherein the thread density is a global Wherein the step of modifying the source code of the general purpose application is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing memory access, Identifying each of the threads accessing the global memory and reused data by the instruction if the density is greater than a predetermined threshold, for example, 1; And a processor configured to execute the steps of: storing, in relation to the identified threads and data, the reused data in the shared memory prior to the start of the identified threads; a syntax for synchronizing threads; And modifying the source code to have a syntax for accessing the identified data from the shared memory.

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 범용 어플리케이션의 소스 코드를 수정하는 단계는 상기 쓰레드 밀도가 소정의 문턱값, 예를 들어 1보다 작으면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및 상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 시에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함할 수 있다.According to one embodiment, analyzing the reuse pattern comprises calculating thread density for each thread group, based on the memory access record and the reuse stack of the thread group, wherein the thread density is a global Wherein the step of modifying the source code of the general purpose application is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing memory access, Identifying each of the threads reusing data and reused data among the threads accessing the global memory by the instruction if the density is less than a predetermined threshold value, for example, 1; And a processor operable to: determine, for the identified threads and data, a syntax for storing the reused data in the shared memory at the start of the identified threads, a syntax for synchronizing threads, And modifying the source code such that threads have a syntax for accessing the identified data from the shared memory.

일 실시예에 따라, 상기 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계; 및 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 범용 어플리케이션의 소스 코드를 수정하는 단계는 상기 재사용 거리가 제1 문턱값보다 클 때에 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계; 상기 쓰레드 밀도가 제2 문턱값보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 전 또는 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문, 상기 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함할 수 있다.According to one embodiment, analyzing the reuse pattern may include calculating reuse distance of each of the data groups that are accessed more than once by threads belonging to the thread group, based on the reuse stack, for each thread group step; And for each thread group, calculating a thread density based on the memory access record and the reuse stack of the thread group, wherein the thread density is determined by an access from global memory by one instruction causing a global memory access Wherein the step of modifying the source code of the general purpose application further comprises the step of determining whether the reuse distance is greater than the first threshold value, Identifying a reuse thread and data to be reused, respectively; Identifying threads accessing the global memory and reused data by the instruction if the thread density is greater than a second threshold; And a statement to store the reused data in the shared memory before or after the identified thread, with respect to the identified thread and data, a syntax for synchronizing threads when the reused data is reused between threads And modifying the source code such that the identified thread has a syntax for accessing the identified data in the shared memory while the identified thread is executing.

일 실시예에 따라, 상기 쓰레드 그룹은 커널이고, 상기 메모리 접근 기록을 생성하는 단계는 전역 메모리 접근을 일으키는 쓰레드의 커널 정보, 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계를 포함하고, 상기 재사용 패턴을 분석하는 단계는 각 커널마다, 상기 재사용 스택에 기초하여, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함하고, 상기 범용 어플리케이션의 소스 코드를 수정하는 단계는 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계; 및 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드를 포함하는 커널의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문과 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함할 수 있다.According to one embodiment, the thread group is a kernel, and the step of generating the memory access record includes generating a memory access record by recording kernel information, thread information and a data index of a thread causing a global memory access And analyzing the reuse pattern includes calculating a reuse distance of each of the data groups accessed by the threads belonging to the kernel more than once based on the reuse stack for each kernel, The step of modifying the source code of the application comprises: identifying a reuse thread and reused data, respectively, based on the reuse distance; And for the identified thread and data, a syntax for storing the reused data in the shared memory after the start of the kernel including the identified thread, and a processor for determining, during execution of the identified thread, And modifying the source code to have a syntax for accessing from the shared memory.

본 발명의 또 다른 측면에 따라 그래픽 프로세서 상에서 범용 어플리케이션의 구동을 분석하는 범용 어플리케이션 분석 장치는 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 메모리 접근 기록 생성부; 상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 재사용 스택 생성부; 및 상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 재사용 패턴 분석부를 포함할 수 있다.According to still another aspect of the present invention, a general-purpose application analyzing apparatus for analyzing the operation of a general-purpose application on a graphics processor monitors global memory access of a general-purpose application before optimization executed on a graphics processor emulator, A memory access record generating unit for recording a data index to generate a memory access record; When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, A reusable stack generating unit for generating a reusable stack for each thread group; And a reuse pattern analyzer for analyzing a reuse pattern of the data groups based on the reuse stack.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작할 수 있다.According to one embodiment, the reuse pattern analyzer may operate for each thread group to calculate a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once, based on the reuse stack have.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의될 수 있다.According to one embodiment, the reuse pattern analyzer is operative to, for each thread group, calculate a thread density based on the memory access record and the reuse stack of the thread group, wherein the thread density is one of causing a global memory access To the number of threads accessed in the global memory by the command.

일 실시예에 따라, 상기 쓰레드 그룹은 커널이고, 상기 메모리 접근 기록은 커널 정보, 쓰레드 정보 및 데이터 인덱스를 포함하도록 생성될 수 있다.According to one embodiment, the thread group is a kernel, and the memory access record may be generated to include kernel information, thread information, and a data index.

본 발명의 또 다른 측면에 따라 공유 메모리를 가지는 그래픽 프로세서 상에서 범용 어플리케이션의 소스 코드를 최적화하는 범용 어플리케이션 최적화 장치는 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 메모리 접근 기록 생성부; 상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 재사용 스택 생성부; 상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 재사용 패턴 분석부; 및 상기 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터에 관하여, 상기 데이터를 상기 공유 메모리에 저장하는 코드를 가지도록 상기 범용 어플리케이션의 소스 코드를 수정하는 소스 코드 수정부를 포함할 수 있다.According to another aspect of the present invention, a general-purpose application optimizing apparatus for optimizing a source code of a general-purpose application on a graphics processor having a shared memory monitors a global memory access of a non-optimization general application running on a graphics processor emulator, A memory access record generation unit for generating a memory access record by recording thread information and a data index of a causing thread; When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, A reusable stack generating unit for generating a reusable stack for each thread group; A reuse pattern analyzer for analyzing a reuse pattern of data groups based on the reuse stack; And a source code modification unit for modifying the source code of the general-purpose application so as to have a code for storing the data in the shared memory with respect to data identified as being reused based on the reuse pattern.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작하고, 상기 소스 코드 수정부는 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하고, 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작할 수 있다.According to one embodiment, the reuse pattern analyzing unit is operable to calculate a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once, for each thread group, based on the reuse stack, Wherein the source code modification unit identifies each of the reusing data and the reused data based on the reuse distance, and for the identified thread and data, reuses the reused data after the start of the identified thread in the shared memory And to modify the source code so that the identified thread has a syntax for accessing the identified data in the shared memory while the identified thread is executing.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 소스 코드 수정부는 상기 쓰레드 밀도가 1보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하고, 상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 후에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정도록 동작할 수 있다.According to one embodiment, the reuse pattern analyzer is operative to, for each thread group, calculate a thread density based on the memory access record and the reuse stack of the thread group, wherein the thread density is one of causing a global memory access Wherein the source code modifier is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by the instruction of the instruction, To identify threads that are accessing the memory and data to be reused, respectively, and for the identified threads and data, a syntax for storing the reused data in the shared memory after the start of the identified threads, Syntax and executing the identified threads May operate to modify the source code so that the identified threads have a syntax for accessing the identified data in the shared memory.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 소스 코드 수정부는 상기 쓰레드 밀도가 1보다 작으면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하고, 상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 시에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작할 수 있다.According to one embodiment, the reuse pattern analyzer is operative to, for each thread group, calculate a thread density based on the memory access record and the reuse stack of the thread group, wherein the thread density is one of causing a global memory access Is defined as a ratio of the number of threads accessed to the global memory by the instruction with respect to the number of data accessed in the global memory by an instruction of the thread, and if the thread density is less than 1, Each of the threads reusing data and reused data among threads accessing the global memory, and for each of the identified threads and data, for reusing the reused data at the start of the identified threads, , A phrase that synchronizes threads And it is operable to modify the source code of said identified thread to the identification data during the execution of the identified thread to have a syntax for access from the shared memory.

일 실시예에 따라, 상기 재사용 패턴 분석부는 각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하고, 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하며, 상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며, 상기 소스 코드 수정부는 상기 재사용 거리가 제1 문턱값보다 클 때에 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하고, 상기 쓰레드 밀도가 제2 문턱값보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하며, 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문, 상기 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작할 수 있다.According to one embodiment, the reuse pattern analyzer calculates a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once, based on the reuse stack, for each thread group, And for each group, the thread density based on the memory access record and the reuse stack of the thread group, the thread density being calculated by multiplying the number of data accessed in the global memory by one instruction causing a global memory access Wherein the reuse distance is defined as a ratio of the number of threads accessing the global memory by the instruction, and the source code modifying unit is configured to reuse the reuse thread based on the reuse distance when the reuse distance is greater than the first threshold, Data, and wherein the thread density is a second threshold value A statement for identifying each of the threads accessing the global memory and reused data by the instruction and for storing the reused data in the shared memory after the start of the identified thread with respect to the identified thread and data, A syntax for synchronizing threads when the reused data is reused between threads, and a syntax for synchronizing threads when the identified thread is running, wherein the identified thread has a syntax for accessing the identified data from the shared memory. Lt; / RTI >

일 실시예에 따라, 상기 쓰레드 그룹은 커널이고, 상기 메모리 접근 기록 생성부는 전역 메모리 접근을 일으키는 쓰레드의 커널 정보, 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하도록 동작하며, 상기 재사용 패턴 분석부는 각 커널마다, 상기 재사용 스택에 기초하여, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작하고, 상기 소스 코드 수정부는 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하며, 식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드를 포함하는 커널의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문과 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작할 수 있다.According to one embodiment, the thread group is a kernel, and the memory access record generator is operative to generate a memory access record by recording kernel information, thread information and a data index of a thread causing a global memory access, Wherein the source code modifier is operative to calculate a reuse distance of each of the data groups accessed by the threads belonging to the kernel more than once based on the reuse stack for each kernel, Identifying a thread reusing data and data to be reused, respectively; identifying, for the identified thread and data, a syntax for storing the reused data in the shared memory after the start of the kernel containing the identified thread; During the execution of the identified thread, And modify the source code to have a syntax for accessing distinct data from the shared memory.

본 발명의 범용 어플리케이션 분석 장치 및 분석 방법에 따르면, 범용 어플리케이션을 그래픽 프로세서에서 최적으로 구동하도록 최적화할 수 있다.According to the general-purpose application analyzing apparatus and analyzing method of the present invention, it is possible to optimize the general-purpose application to be optimally driven in the graphic processor.

본 발명의 범용 어플리케이션 분석 장치 및 분석 방법에 따르면, 범용 어플리케이션을 그래픽 프로세서에서 구동하기 위해, 어플리케이션의 메모리 접근 패턴을 분석하고 프로파일링하여 실행 시에 재사용되는 데이터를 식별할 수 있다.According to the general-purpose application analyzing apparatus and analyzing method of the present invention, in order to drive the general-purpose application on the graphics processor, the memory access pattern of the application can be analyzed and profiled to identify the data to be reused at the time of execution.

본 발명의 범용 어플리케이션 분석 장치 및 분석 방법에 따르면, 실행 시에 재사용되는 것으로 식별된 데이터에 관하여, 이러한 데이터들이 GPGPU의 공유 메모리에 캐싱되도록 만드는 코드를 범용 어플리케이션의 소스 코드 내에 자동으로 삽입함으로써, 범용 어플리케이션을 GPGPU의 메모리 아키텍처에 최적화할 수 있다.According to the general-purpose application analysis apparatus and method of the present invention, with respect to the data identified as being reused at the time of execution, by automatically inserting the code for causing such data to be cached in the GPGPU's shared memory into the source code of the general- Applications can be optimized for GPGPU's memory architecture.

본 발명의 효과는 이상에서 언급된 것들에 한정되지 않으며, 언급되지 아니한 다른 효과들은 아래의 기재로부터 당업자에게 명확하게 이해될 수 있을 것이다.The effects of the present invention are not limited to those mentioned above, and other effects not mentioned can be clearly understood by those skilled in the art from the following description.

도 1은 본 발명의 일 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법을 예시한 순서도이다.
도 2는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 생성되는 재사용 스택을 예시한 모식도이다.
도 3은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 쓰레드 내의 데이터 재사용을 예시한 모식도이다.
도 4는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서, 쓰레드 내의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.
도 5는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 쓰레드들 간의 데이터 재사용이 빈번한 상태를 예시한 모식도이다.
도 6은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서, 쓰레드들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.
도 7은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서, 쓰레드들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.
도 8은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 커널들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.
도 9는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 장치를 예시한 블록도이다.
1 is a flowchart illustrating a general-purpose application analysis and optimization method according to an embodiment of the present invention.
2 is a schematic diagram illustrating a reusable stack generated in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
3 is a schematic diagram illustrating reuse of data in a thread analyzed in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
4 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data in a thread can be reused in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
5 is a schematic diagram illustrating a state in which data reuse frequently occurs among threads analyzed in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
6 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between threads in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
7 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between threads in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
8 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between kernels analyzed in a general-purpose application analysis and optimization method according to an embodiment of the present invention.
9 is a block diagram illustrating a general-purpose application analysis and optimization apparatus according to an embodiment of the present invention.

본문에 개시되어 있는 본 발명의 실시예들에 대해서, 특정한 구조적 내지 기능적 설명들은 단지 본 발명의 실시예를 설명하기 위한 목적으로 예시된 것으로, 본 발명의 실시예들은 다양한 형태로 실시될 수 있으며 본문에 설명된 실시예들에 한정되는 것으로 해석되어서는 아니 된다.For the embodiments of the invention disclosed herein, specific structural and functional descriptions are set forth for the purpose of describing an embodiment of the invention only, and it is to be understood that the embodiments of the invention may be practiced in various forms, The present invention should not be construed as limited to the embodiments described in Figs.

이하, 첨부한 도면들을 참조하여, 본 발명의 바람직한 실시예를 보다 상세하게 설명하고자 한다. 도면상의 동일한 구성요소에 대해서는 동일한 참조부호를 사용하고 동일한 구성요소에 대해서 중복된 설명은 생략한다.Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings. The same reference numerals are used for the same constituent elements in the drawings and redundant explanations for the same constituent elements are omitted.

본 발명은, 프로그래머가 GPGPU 프로그래밍 모델을 이용하여 최신의 GPGPU와 같이 공유 메모리를 가지는 그래픽 프로세서를 기반으로 범용 병렬연산 어플리케이션을 작성하고 구동하는 데에 있어서, 프로그래머가 특정 GPGPU의 하드웨어 아키텍처, 해당 어플리케이션의 병렬성, 해당 어플리케이션의 구동 시에 특정 CPU와 특정 GPU의 협업 관계 등에 관한 깊은 이해를 갖지 않더라도, 해당 범용 병렬연산 어플리케이션에 관하여 상당한 수준의 최적화를 달성하기 위한 방법론에 관한 것이다. 나아가, "범용 어플리케이션"은 그래픽 프로세서의 원래 용도인 그래픽 처리에 비하여 상대적으로 다각화된 용도, 예를 들어 암호화 용도의 어플리케이션을 의미한다.The present invention is based on the assumption that a programmer uses a GPGPU programming model to create and operate a general purpose parallel computing application based on a graphics processor having a shared memory such as the latest GPGPU, To a methodology for achieving a significant level of optimization with respect to a general-purpose parallel computing application, without having a deep understanding of the parallelism, the cooperative relationship of a particular CPU with a particular GPU at the time of launching the application. Furthermore, the term "general purpose application " refers to a relatively diversified application, for example, an application for encryption, as compared to the graphics processing, which is the original use of the graphics processor.

도 1은 본 발명의 일 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법을 예시한 순서도이다.1 is a flowchart illustrating a general-purpose application analysis and optimization method according to an embodiment of the present invention.

도 1을 참조하면, 범용 어플리케이션 분석 및 최적화 방법은 컴퓨터를 이용하여, 공유 메모리를 가지는 그래픽 프로세서 상에서 범용 어플리케이션의 소스 코드를 분석하고 최적화할 수 있다.Referring to FIG. 1, a general-purpose application analysis and optimization method can use a computer to analyze and optimize a general-purpose application source code on a graphic processor having a shared memory.

이를 위해, 단계(S11)에서, 컴퓨터가, 그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 어플리케이션의 전역(global) 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성할 수 있다.To this end, in step S11, the computer monitors the global memory access of the pre-optimization application running on the graphics processor emulator, records the thread information and the data index of the thread causing the global memory access, Can be generated.

예를 들어 조지아텍(Georgia Tech)에서 제공하는 GPUOcelot과 같은 그래픽 프로세서 에뮬레이터는 명령어 기반의 그래픽 프로세서 에뮬레이션 프레임워크로서, 그래픽 프로세서와 어플리케이션 사이의 런타임 API를 대체하여, 그래픽 프로세서에서 어플리케이션이 구동될 때에 동적 분석 기능의 일환으로서 전역 메모리 접근을 추적할 수 있다.For example, a graphics processor emulator, such as GPUOcelot, available from Georgia Tech, is a command-based graphics processor emulation framework that replaces the runtime API between a graphics processor and an application, As part of the analysis function, global memory access can be tracked.

이러한 전역 메모리 접근의 추적 기능을 따라, 전역 메모리 접근을 일으키는 쓰레드들의 정보와 그 쓰레드들이 접근하는 데이터의 인덱스가 기록될 수 있다. 본 명세서에서 데이터 인덱스는 예를 들어 어플리케이션 내에서 선언되는 상수 내지 변수를 개별적으로 식별할 수 있는 여하한 형태의 정보를 포괄적으로 지칭한다.Following this trace of global memory access, information about the threads that cause global memory access and the indexes of the data that the threads access can be recorded. The data index herein collectively refers to any type of information that can individually identify constants or variables that are declared in an application, for example.

이때, 본 발명의 그래픽 프로세서 에뮬레이터는 어플리케이션에서 일어나는 모든 형태의 메모리 접근이 아니라, GPU 내의 개별 스트리밍 프로세서에 할당되어 구동되는 쓰레드가 다루어야 하는 변수나 상수가 GPU의 그래픽 메모리 내의 전역 메모리 공간 내에 저장되어 있어서, 쓰레드의 처리를 위해서 스트리밍 프로세서가 그래픽 메모리까지 접근하게 되는 전역 메모리 접근을 추적한다는 점에 유의한다.At this time, the graphic processor emulator of the present invention is not a memory access of all types occurring in an application, but a variable or a constant to be handled by a thread allocated to an individual streaming processor in the GPU to be operated is stored in the global memory space in the graphic memory of the GPU Note that the streaming processor tracks global memory accesses to the graphics memory for processing of threads.

//위 문단의 내용이 기술적으로 맞는지 확인해주세요.//// Please make sure the contents of the above paragraph are technically correct. //

다음으로, 단계(S12)에서, 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 컴퓨터가, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성할 수 있다.Next, in step S12, when a plurality of threads recorded in the memory access record constitute a plurality of thread groups, the computer sets at least one data accessed by threads belonging to each thread group for each thread group A plurality of clustered data groups can be arranged in the order in which they are accessed, and a reuse stack can be created for each thread group.

재사용 스택(Reuse Stack)은 쓰레드 그룹들이 전역 메모리 접근을 일으키면서 접근하는 데이터 그룹들을 각 쓰레드 그룹마다 접근 순서대로 쌓아 시각화한 개념이다. 쓰레드 그룹마다 데이터 그룹들에 기초하는 재사용 스택을 예시하기 위해 도 2를 참조한다.The Reuse Stack is a concept that visualizes the data groups accessed by thread groups as they cause global memory access by stacking them in order of access for each thread group. Reference is made to Fig. 2 for illustrating a reuse stack based on data groups for each thread group.

도 2는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 생성되는 재사용 스택을 예시한 모식도이다.2 is a schematic diagram illustrating a reusable stack generated in a general-purpose application analysis and optimization method according to an embodiment of the present invention.

도 2에서, 가장 위쪽에 예시된 바와 같이, 메모리 접근 기록을 분석하면, 특정 쓰레드들로 구성된 쓰레드 그룹이 실행 중에 전역 메모리 접근에 따라 접근되는 데이터 그룹들이 접근 순서대로 나열될 수 있다.In FIG. 2, as illustrated at the top, analyzing memory access records allows data groups to be accessed in order of access in accordance with global memory access during execution of a thread group consisting of specific threads.

여기서 쓰레드 그룹은 쓰레드들의 집합으로서, 하나의 스트리밍 멀티프로세서에 할당되어 서로 데이터를 교환하면서 연산될 수 있는 쓰레드들로 구성된 쓰레드블록일 수도 있고, 실시예에 따라서는 하나의 커널(kernel)일 수도 있다.Here, the thread group is a set of threads, which may be a thread block made up of threads that can be allocated to one streaming multiprocessor and exchanged with each other, and may be a single kernel depending on the embodiment .

쓰레드 그룹이 쓰레드블록일 경우에, 쓰레드블록 내의 쓰레드들은 일정한 데이터들을 서로 교환할 수 있는데, 쓰레드블록에 속하는 쓰레드들이 공유 메모리에 데이터들을 저장하고 공유 메모리로부터 데이터를 읽음으로써 가능하게 된다.When a thread group is a thread block, threads in a thread block can exchange certain data, which is made possible by threads belonging to a thread block storing data in the shared memory and reading data from the shared memory.

실제로, 예를 들어 CUDA와 같은 GPGPU 프로그래밍 모델의 컴파일러는 서로 공유할 수 있는 데이터들을 가지는 쓰레드들을 모아 쓰레드블록을 구성한다.In practice, for example, a compiler in the GPGPU programming model, such as CUDA, constructs a thread block by aggregating threads with data that can be shared with each other.

다시 말해, 만약 쓰레드블록 내의 어떤 쓰레드가 전역 메모리 접근을 일으키면서 어떤 데이터에 접근한다면, 그 쓰레드블록 내의 다른 쓰레드가 전역 메모리 접근을 통해 접근하는 다른 데이터는 위 데이터와 매우 밀접한 관계가 있음을 알 수 있다. 예를 들어 쓰레드블록 내의 쓰레드들이 취급하는 데이터들은 하나의 배열(array)을 구성하는 데이터들일 수 있다. In other words, if a thread in a thread block accesses some data while causing a global memory access, the other data in the thread block that the other thread accesses through global memory access has a close relationship with the above data have. For example, the data handled by threads in a thread block may be the data that constitutes an array.

이에 따라, 본 발명의 범용 어플리케이션 분석 및 최적화 방법은 예를 들어 쓰레드블록과 같은 쓰레드 그룹마다, 쓰레드 그룹이 전역적으로 접근하는 데이터들의 그룹인 데이터 그룹들을 특정하고, 각 데이터 그룹들이 어떻게 재사용되는지 분석할 수 있도록, 여러 데이터 그룹들로써 재사용 스택을 생성할 수 있다. Accordingly, the general-purpose application analysis and optimization method of the present invention specifies data groups that are groups of data globally accessed by a thread group, for example, for each thread group such as a thread block, and analyzes how data groups are reused You can create a reuse stack with multiple data groups, so that you can do it.

그러한 재사용 스택은, 쓰레드 그룹이 실행되기 시작한 때에, 도 2에서 중간의 세 스택들과 같이 예시된다. 중간의 세 스택들 중 좌측의 스택은 데이터 그룹이 하나인 때의 재사용 스택을 예시한다. tid가 0부터 255인 쓰레드들로써 군집화된 쓰레드 그룹의 실행 시에, 256 개의 쓰레드들 중 적어도 하나의 쓰레드가 전역 메모리 접근에 의해 전역 메모리의 데이터 그룹 A[0-255] 중 적어도 하나의 데이터에 접근하였음을 의미한다.Such a reuse stack is illustrated as the middle three stacks in FIG. 2 when the thread group begins to run. The stack on the left of the middle three stacks illustrates the reuse stack when the data group is one. At least one thread of 256 threads accesses at least one of data groups A [0-255] in global memory by global memory access when executing a clustered thread group with tid from 0 to 255 .

중간의 재사용 스택은 쓰레드 그룹이 좀더 오래 실행되면서, 전역 메모리의 데이터 그룹 A[0-255] 내의 적어도 하나의 데이터에 접근한 후에, 전역 메모리의 데이터 그룹 A[256-511]에 2 회에 걸쳐 연속 접근하였음을 의미한다.The intermediate reuse stack is accessed twice in the data group A [256-511] of the global memory after accessing at least one data in the data group A [0-255] of the global memory while the thread group is running for a longer time It means that it is consecutive approach.

우측의 재사용 스택은 쓰레드 그룹이 오래 실행되면서, 전역 메모리의 데이터 그룹 A[0-255]에 접근한 후에, 전역 메모리의 데이터 그룹 A[256-511]에 두 번 연속 접근하였다가, 전역 메모리의 데이터 그룹 A[0-255]와 데이터 그룹 A[512-767]에 접근하였음을 의미한다.The reuse stack on the right side accesses the data group A [0-255] of the global memory while the thread group is running for a long time, accesses the data group A [256-511] of the global memory twice consecutively, It means that data group A [0-255] and data group A [512-767] have been accessed.

각 시점의 재사용 스택들을 살펴보면, 해당 쓰레드 그룹이 실행되는 동안 데이터 그룹 A[0-255]와 A[255-511]가 각각 적어도 한 차례 재사용됨을 알 수 있다.Looking at the reuse stacks at each point in time, it can be seen that the data groups A [0-255] and A [255-511] are reused at least once during the thread group execution.

이러한 재사용 스택을 기초로 각 쓰레드 그룹마다 재사용되는 데이터 그룹들을 특정할 수 있고, 재사용되는 데이터 그룹들이 어떻게 재사용되는지 분석할 수 있다.Based on this reuse stack, it is possible to specify data groups to be reused for each thread group, and analyze how reused data groups are reused.

이제 다시 도 1로 돌아가서, 단계(S13)에서, 컴퓨터가 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석할 수 있다.Returning now again to FIG. 1, in step S13, the computer may analyze the reuse pattern of data groups based on the reuse stack.

다음으로, 단계(S14)에서, 컴퓨터가 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터(또는 데이터 그룹)에 관하여, 그러한 데이터를 공유 메모리에 저장하는 코드를 가지도록 어플리케이션의 소스 코드를 수정할 수 있다.Next, in step S14, the source code of the application may be modified to have code for storing such data in the shared memory, with respect to the data (or data group) identified as being reused based on the reuse pattern .

데이터 그룹의 재사용 패턴은 데이터 또는 데이터 그룹이 하나의 쓰레드 내에서 재사용되는 경우와 서로 다른 쓰레드들에 의해 반복적으로 사용되는 경우로 나눌 수 있고, 데이터 또는 데이터 그룹이 커널들 사이에 재사용되는 경우도 생각해볼 수 있다.The reuse pattern of a data group can be divided into a case in which a data or a data group is reused in one thread and a case in which the data or a data group is repeatedly used by different threads, You can try.

먼저, 쓰레드 내에서 데이터 재사용이 일어나는 경우의 분석 및 최적화를 위해, 단계(S13)는 컴퓨터가 각 쓰레드 그룹마다, 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함할 수 있다.First, in order to analyze and optimize when data reuse occurs in the thread, step S13 determines whether or not the data that is accessed by the computer at least two times by each thread group, based on the reuse stack, And calculating the reuse distance of each of the groups.

재사용 거리의 산출은 데이터 그룹이 2 회 이상 접근되어 재사용 스택 내에 2 회 이상 기록되어 있을 때에 기록된 가장 최신의 두 위치들 사이의 거리로서 산출될 수 있다. 실시예에 따라, 재사용 거리의 산출은, 2 회 연속적으로 재사용될 경우에 "0", 비연속적으로 2회 이상 재사용될 경우에 거리에 상관없이 "1", 재사용되지 않으면 "-1"과 같이 주어질 수도 있다. 예를 들어, 도 2의 우측 재사용 스택에서, 데이터 그룹 A[0-255]은 스택 인덱스 0과 스택 인덱스 3에 기록되어 그 재사용 거리가 "1"이고, 데이터 그룹 A[255-511]은 스택 인덱스 1과 스택 인덱스 2에 기록되어 그 재사용 거리가 "0"이며, A[512-767]은 스택 인덱스 4에 기록되어 그 재사용 거리가 "-1"로 주어질 수 있다.The calculation of the reuse distance can be calculated as the distance between the two most recent positions recorded when the data group is accessed more than once in the reuse stack and more than once in the reuse stack. According to the embodiment, the calculation of the reuse distance can be made as follows: "0" when reused two times consecutively, "1" irrespective of distance when reused two or more times discontinuously, May be given. For example, in the right reuse stack of FIG. 2, data group A [0-255] is recorded in stack index 0 and stack index 3, its reuse distance is "1 ", data group A [255-511] The reuse distance is "0 ", and A [512-767] is recorded in the stack index 4 so that the reuse distance can be given as" -1 ".

쓰레드 내에서 데이터 그룹의 재사용이 일어나는 경우를 예시하기 위해 도 3 및 도 4를 참조하면, 도 3은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 쓰레드 내의 데이터 재사용을 예시한 모식도이고, 도 4는 쓰레드 내의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.3 and 4 to illustrate reuse of a data group in a thread, FIG. 3 is a schematic diagram illustrating reuse of data in a thread analyzed in a general-purpose application analysis and optimization method according to an embodiment of the present invention. And FIG. 4 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data in a thread can be reused.

도 3에서, 예시된 간단한 코드는 두 개의 중첩된 반복문들에 의해 배열 A의 일부와 배열 B의 일부를 반복적으로 참조하는 동작을 수행한다.In Figure 3, the illustrated simple code performs an operation of iteratively referencing a portion of array A and a portion of array B by two nested loops.

쓰레드가 실행된 직후에, 외부 반복문에서 i=0이고 내부 반복문에서 j=0인 때에, 쓰레드는 배열 A의 A[0-255]와 배열 B의 B[0-255]를 각각 전역 메모리에서 읽어와서 연산하고 그 결과를 도출한다. 이어서, 내부 반복문에서 j=1이 되고, 쓰레드는 배열 A의 A[0-255]를 다시 읽어들이지만, 배열 B의 경우에는 B[256-511]를 읽어와서 연산한다. 이후에 내부 반복문의 반복이 종결될 때까지, 쓰레드는 배열 A의 A[0-255]를 계속 재사용한다.Immediately after the thread is executed, when i = 0 in the outer loop and j = 0 in the inner loop, the thread reads A [0-255] in array A and B [0-255] To calculate and derive the result. Then, j = 1 in the inner loop, and the thread re-reads A [0-255] in array A, but in the case of array B, it reads B [256-511]. Then the thread continues to reuse A [0-255] in array A until the iteration of the inner loop is terminated.

외부 반복문에서 i가 점증하여 i=1이 되고 내부 반복문에서 j=0으로 되돌아가면, 쓰레드는 배열 A의 A[256-512]와 배열 B의 B[0-255]를 각각 전역 메모리에서 읽어와서 연산하고 그 결과를 도출한다. 이어서, 내부 반복문에서 j=1이 되고, 쓰레드는 배열 A의 A[256-512]를 다시 읽어들이지만, 배열 B의 경우에는 B[256-511]를 읽어와서 연산한다. 이후에 내부 반복문의 반복이 종결될 때까지, 쓰레드는 배열 A의 A[256-512]를 계속 재사용한다.When i is incremented in the outer loop and i = 1 and j = 0 in the inner loop, the thread reads A [256-512] in array A and B [0-255] in array B respectively from global memory And derives the result. Then, j = 1 in the inner loop, and the thread reads A [256-512] of array A again, but in case of array B, it reads B [256-511]. The thread then continues to reuse A [256-512] in array A until the iteration of the inner loop is terminated.

이 경우에, 쓰레드는 안쪽 반복문을 처리하는 동안에는 매 루프마다 배열 A를 재사용하고 외부 반복문을 처리할 때에는 n 루프마다 한 번씩 배열 B도 재사용한다.In this case, the thread reuses array A every loop while processing the inner loop, and reuses array B once every n loops when processing the outer loop.

이렇게 하나의 쓰레드 내에서 데이터 그룹이 재사용되는 경우에는, 재사용되는 것으로 식별된 데이터 그룹을, 이 데이터 그룹을 재사용하는 쓰레드가 데이터 그룹을 재사용하기 전에, 전역 메모리로부터, 그 쓰레드가 속하는 쓰레드 그룹이 할당된 스트림 멀티프로세서의 공유 메모리로 옮겨놓으면, 쓰레드가 특정 데이터 그룹을 참조할 때에 그래픽 카드의 전역 메모리에 복수 회 접근하는 데에 걸리는 시간을 상당히 절감할 수 있다.In the case where a data group is reused in one thread, a data group identified as being reused is allocated from a global memory before a thread reusing the data group reuses the data group. Stream into a multiprocessor shared memory can significantly reduce the amount of time it takes to access the graphics card's global memory multiple times when a thread references a particular group of data.

이에 따라, 단계(S14)인 어플리케이션의 소스 코드를 수정하는 단계는 컴퓨터가, 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계 및 식별된 쓰레드와 데이터에 관하여, 식별된 쓰레드의 시작 후에 재사용되는 데이터를 공유 메모리에 저장하는 구문 및 식별된 쓰레드가 실행되는 동안에 식별된 쓰레드가 식별된 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정하는 단계를 포함할 수 있다.Thus, the step of modifying the source code of the application, which is step S14, comprises the steps of: the computer identifying each of the reusing data and the reusing data based on the reuse distance, and identifying And storing the reused data in the shared memory after the start of the identified thread, and modifying the source code such that the identified thread has the syntax for accessing the identified data from the shared memory during execution of the identified thread have.

예를 들어, 도 4에서, 소스 코드는 쓰레드가 어떤 데이터 그룹을 재사용하기 전에, 예를 들어 외부 반복문 앞에, 재사용될 데이터 그룹을 공유 메모리에 저장할 임시 배열을 선언하는 구문과, 외부 반복문 안에 재사용될 데이터 그룹을 전역 메모리로부터 읽어와서 공유 메모리에 저장하는 구문을 더 포함하도록 수정될 수 있다.For example, in FIG. 4, the source code includes a syntax for declaring a temporary array to store a group of data to be reused in a shared memory before an external loop, for example, before a thread reuses a certain data group, And a syntax for reading the data group from the global memory and storing it in the shared memory.

또한, 소스 코드가 내부 반복문 안쪽에서 재사용될 데이터 그룹의 식별명을 앞서 선언한 임시 배열의 식별명으로 변경하는 식으로 수정됨으로써, 식별된 쓰레드가 실행되는 동안에, 식별된 쓰레드는 식별된 재사용 데이터를 공유 메모리에서 접근할 수 있다.The source code is also modified to change the identifier of the data group to be reused inside the inner loop to the identifier of the declared temporary array so that during the execution of the identified thread, It can be accessed from shared memory.

한편, GPGPU 어플리케이션에서, 쓰레드블록을 이루는 쓰레드들은 공유 메모리를 통해 데이터를 교환할 수 있으므로, 쓰레드들 사이에 데이터의 재사용이 가능함을 의미한다.On the other hand, in GPGPU application, threads forming a thread block can exchange data through shared memory, meaning that data can be reused between threads.

이에 따라, 쓰레드들 사이에서 데이터 재사용이 일어나는 경우의 분석 및 최적화를 위해, 단계(S13)는 컴퓨터가, 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 메모리 접근 기록 및 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함할 수 있다. Accordingly, in order to analyze and optimize when data reuse occurs between threads, step S13 calculates the thread density based on the memory access record and reuse stack of the thread group for each thread group Step < / RTI >

이때, 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비(threads/data)로 정의될 수 있다.At this time, the thread density can be defined as the ratio (threads / data) of the number of threads accessing the global memory by the instruction to the number of data accessed from the global memory by one instruction causing the global memory access .

쓰레드 밀도의 개념을 예시하기 위해 도 5를 참조하면, 도 5는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 쓰레드들 간의 데이터 재사용이 빈번한 상태를 예시한 모식도이다.FIG. 5 is a schematic diagram illustrating a state in which data reuse between threads analyzed frequently in a general-purpose application analysis and optimization method according to an embodiment of the present invention is frequent.

도 5에서, 만약 쓰레드블록을 구성하는 여러 쓰레드들이 전역 메모리 내의 어떤 동일한 데이터에 각자 접근한다면 전역 메모리의 지연 시간은 상당히 클 수 있다.In FIG. 5, if multiple threads constituting a thread block access each other to some identical data in the global memory, the delay time of the global memory may be considerably large.

이를 좀더 일반화하면, 쓰레드들의 개수를 데이터들의 개수로 나눈 값이 소정의 문턱값, 예를 들어 1보다 크면, 적어도 두 쓰레드들이 전역 메모리에서 하나의 공통된 데이터에 접근한다고 볼 수 있다. 쓰레드 밀도가 1보다 클수록, 다시 말해, 재사용되는 데이터의 개수가 쓰레드들의 개수보다 훨씬 적을수록, 어느 두 쓰레드들이 더 많은 수의 공통된 데이터들에 접근한다고 추정할 수 있다. More generally, if a value obtained by dividing the number of threads by the number of data is greater than a predetermined threshold value, for example, 1, at least two threads can access a common data in the global memory. It can be inferred that as the thread density is greater than 1, that is, the number of reused data is much less than the number of threads, which two threads access a larger number of common data.

따라서, 쓰레드 밀도가 1보다 크고, 나아가 1보다 훨씬 크면, 일부 쓰레드들 사이에 공통되어 재사용될 데이터를 공유 메모리에 미리 저장함으로써, 전역 메모리에 접근하기 위한 지연 시간을 줄이고 성능 향상을 도모할 수 있다.Therefore, if the thread density is larger than 1 and much larger than 1, the data to be reused in common among some threads is stored in the shared memory in advance, so that the delay time for accessing the global memory can be reduced and the performance can be improved .

이렇게 쓰레드들 간에 데이터 그룹이 재사용되는 경우에는, 재사용되는 것으로 식별된 데이터 그룹을, 이 데이터 그룹을 재사용하는 쓰레드가 실행되기 전에, 전역 메모리로부터, 그 쓰레드가 속하는 쓰레드 그룹이 할당된 스트림 멀티프로세서의 공유 메모리로 옮겨놓으면, 쓰레드가 특정 데이터 그룹을 참조할 때에 그래픽 카드의 전역 메모리에 복수 회 접근하는 데에 걸리는 시간을 상당히 절감할 수 있다.If the data group is reused between the threads, the data group identified as being reused is read from the global memory before the thread reusing the data group is executed, and the data group of the stream multi-processor to which the thread group to which the thread belongs is assigned Moving to shared memory can significantly reduce the amount of time it takes to access the graphics card's global memory multiple times when a thread references a particular group of data.

이에 따라, 단계(S14)인 어플리케이션의 소스 코드를 수정하는 단계는, 쓰레드 밀도가 소정의 문턱값, 예를 들어 1보다 크면, 컴퓨터가, 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계 및 식별된 쓰레드들과 데이터들에 관하여, 식별된 쓰레드들의 시작 후에 재사용되는 데이터들을 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 식별된 쓰레드들을 실행되는 동안에 식별된 쓰레드들이 식별된 데이터들을 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정하는 단계를 포함할 수 있다.Accordingly, the step of modifying the source code of the application, which is step S14, is a step in which, if the thread density is greater than a predetermined threshold value, for example, 1, the computer reads the threads accessing the global memory by the instruction and the reused data Identifying, in relation to the identified threads and data, a syntax for storing data to be reused in the shared memory after the start of identified threads, a syntax for synchronizing threads, and for identifying identified threads And modifying the source code to have a syntax for accessing the identified data from the shared memory.

예를 들어, 도 6은 쓰레드들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.For example, FIG. 6 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between threads.

도 6을 참조하면, 소스 코드는 쓰레드들이 어떤 데이터 그룹을 재사용하기 전에, 예를 들어 반복문 앞에, 재사용될 데이터 그룹을 공유 메모리에 저장할 임시 배열을 선언하는 구문, 반복문 안에서 재사용될 데이터 그룹을 전역 메모리로부터 읽어와서 공유 메모리에 저장하는 구문 및 쓰레드 그룹에 속하는 쓰레드들을 동기화시키는 구문을 더 포함하도록 수정될 수 있다.Referring to FIG. 6, the source code includes a syntax for declaring a temporary array to be stored in a shared memory before a thread reuses a data group, for example, before a loop statement, a data group to be reused in a loop, And a syntax for storing threads in the shared memory and for synchronizing threads belonging to the thread group.

또한, 소스 코드가 반복문 안에서 재사용될 데이터 그룹의 식별명을 앞서 선언한 임시 배열의 식별명으로 변경하는 식으로 수정됨으로써, 식별된 쓰레드가 실행되는 동안에, 식별된 쓰레드는 식별된 재사용 데이터를 공유 메모리에서 접근할 수 있다.In addition, the source code is modified to change the identifier of the data group to be reused in the loop to the declared temporary array's distinguished name, so that while the identified thread is executing, the identified thread can access the identified re- .

반면에, 쓰레드 밀도가 소정의 문턱값, 예를 들어 1보다 작으면, 다시 말해, 재사용되는 데이터들의 개수가 쓰레드들의 개수보다 크다면, 대체로 쓰레드들 사이에 공통될 데이터가 있을 가능성이 낮아지겠지만, 이때에도 동일한 데이터를 공통적으로 참조하는 쓰레드들이 있을 수 있다.On the other hand, if the thread density is less than a predetermined threshold, for example 1, i.e., if the number of reused data is greater than the number of threads, then there is generally less chance of data being common between threads, At this time, there may be threads that refer to the same data in common.

이에 따라, 단계(S14)인 어플리케이션의 소스 코드를 수정하는 단계는, 컴퓨터가, 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계 및 식별된 쓰레드들과 데이터들에 관하여, 재사용되는 데이터들을 식별된 쓰레드들의 시작 시에 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 쓰레드들을 실행되는 동안에 쓰레드들이 데이터들을 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정하는 단계를 포함할 수 있다.Thus, the step of modifying the source code of the application, which is step S14, comprises the steps of: the computer identifying each of the threads reusing data and reused data among the threads accessing the global memory by instruction, With respect to threads and data, the syntax for storing reused data in shared memory at the start of identified threads, the syntax for synchronizing threads, and the syntax for threads to access data in shared memory during execution And modifying the source code.

예를 들어, 도 7은 쓰레드들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.For example, FIG. 7 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between threads.

도 7을 참조하면, 소스 코드는 쓰레드들이 어떤 데이터 그룹을 재사용하기 전에, 예를 들어 반복문 안에서, 재사용될 데이터 그룹을 공유 메모리에 저장할 임시 배열을 선언하는 구문과, 반복문 안에서 재사용될 데이터 그룹을 전역 메모리로부터 읽어와서 공유 메모리에 저장하는 구문 및 쓰레드 그룹에 속하는 쓰레드들을 동기화시키는 구문을 더 포함하도록 수정될 수 있다.Referring to FIG. 7, the source code includes a syntax for declaring a temporary array to store a group of data to be reused in a shared memory, for example, in a loop, before a thread reuses a certain data group, Syntax for reading from memory and storing in shared memory, and syntax for synchronizing threads belonging to a thread group.

또한, 소스 코드가 반복문 안에서 재사용될 데이터 그룹의 식별명을 앞서 선언한 임시 배열의 식별명으로 변경하는 식으로 수정됨으로써, 식별된 쓰레드가 실행되는 동안에, 식별된 쓰레드는 식별된 재사용 데이터를 공유 메모리에서 접근할 수 있다.In addition, the source code is modified to change the identifier of the data group to be reused in the loop to the declared temporary array's distinguished name, so that while the identified thread is executing, the identified thread can access the identified re- .

도 7에서 예시적으로 수정되는 구문들은 반복문 안에 삽입되는 데에 비해 도 6에서 예시적으로 수정되는 구문들은 반복문 앞에 삽입된다는 점에 유의한다.Note that the phrases that are exemplary modified in FIG. 7 are inserted in the loop, whereas the phrases that are modified in FIG. 6 are inserted before the loop.

한편, 쓰레드 내에서 데이터 재사용과 쓰레드들 간에서 데이터 재사용은 얼마든지 동시에 나타날 수 있기 때문에, 실시예들에 따라, 이들을 함께 고려할 수도 있다. 하지만 공유 메모리의 크기가 한정된다는 점도 고려되어야 한다.On the other hand, since data reuse in threads and data reuse between threads can occur at any time, they may be considered together according to embodiments. However, the size of the shared memory is also limited.

이러한 실시예에서는, 재사용 거리와 쓰레드 밀도는 함께 산출될 수 있다.In this embodiment, the reuse distance and the thread density can be calculated together.

이에 따라, 단계(S13)의 재사용 패턴을 분석하는 단계는 각 쓰레드 그룹마다, 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계와 각 쓰레드 그룹마다, 해당 쓰레드 그룹의 메모리 접근 기록 및 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 함께 포함할 수 있다.Accordingly, the step of analyzing the reuse pattern in the step S13 calculates the reuse distance of each of the data groups that are accessed more than once by the threads belonging to the thread group, on the basis of the reuse stack, for each thread group And for each thread group, calculating the thread density based on the memory access record and reuse stack of the thread group.

또한, 재사용 거리가 소정 크기 이상일 때 또는 쓰레드 밀도가 소정 값 이상일 때에 공유 메모리를 통해 데이터 재사용을 수행하도록 설정될 수 있다.Further, it can be set to perform data reuse through the shared memory when the reuse distance is equal to or larger than a predetermined size or when the thread density is equal to or larger than a predetermined value.

이를 위해, 단계(S14)의 어플리케이션의 소스 코드를 수정하는 단계는, 컴퓨터가, 재사용 거리가 제1 문턱값보다 클 때에, 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계와, 쓰레드 밀도가 제2 문턱값보다 크면, 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계를 포함할 수 있다.To this end, the step of modifying the source code of the application of step S14 comprises the steps of: when the re-use distance is greater than the first threshold value, the computer identifies the re- And identifying each of the threads accessing the global memory and reused data by an instruction if the thread density is greater than a second threshold value.

다음으로, 단계(S14)의 어플리케이션의 소스 코드를 수정하는 단계는, 컴퓨터가, 식별된 쓰레드와 데이터에 관하여, 재사용되는 데이터를 식별된 쓰레드의 시작 후에 공유 메모리에 저장하는 구문, 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에 쓰레드들을 동기화하는 구문 및 쓰레드가 실행되는 동안에 쓰레드가 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정하는 단계를 포함할 수 있다.Next, the step of modifying the source code of the application of step S14 comprises the steps of: the computer storing, in relation to the identified thread and data, the reuse data stored in the shared memory after the start of the identified thread; And may include modifying the source code to have a syntax for synchronizing threads when reused between threads and a syntax for a thread to access data in shared memory while the thread is executing.

도 1로 돌아가서, 실시예에 따라, 쓰레드 그룹은 커널(kernel)일 수 있다.Returning to Figure 1, according to an embodiment, a thread group may be a kernel.

이 경우에 메모리 접근 기록은 커널 정보, 쓰레드 정보 및 데이터 인덱스를 포함하도록 생성될 수 있다.In this case, the memory access record may be generated to include kernel information, thread information, and data indexes.

이에 따라, 단계(S13)의 재사용 패턴을 분석하는 단계는 컴퓨터가, 각 커널마다, 재사용 스택에 기초하여, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함할 수 있다.Accordingly, the step of analyzing the reuse pattern in the step S13 calculates the reuse distance of each of the data groups accessed by the threads belonging to the kernel two or more times, based on the reuse stack, for each kernel .

또한 단계(S14)의 어플리케이션의 소스 코드를 수정하는 단계는 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계 및 식별된 쓰레드와 데이터에 관하여, 식별된 쓰레드를 포함하는 커널의 시작 후에, 재사용되는 데이터를 공유 메모리에 저장하는 구문과, 식별된 쓰레드가 실행되는 동안에 식별된 쓰레드가 식별된 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정하는 단계를 포함할 수 있다.In addition, the step of modifying the source code of the application of step S14 comprises the steps of: identifying a thread reusing data and reusing data, respectively, based on the reuse distance; and identifying, with respect to the identified thread and data, A step of storing the reused data in the shared memory after the start of the kernel and a step of modifying the source code so that the identified thread during the execution of the identified thread has a syntax for accessing the identified data from the shared memory .

도 8은 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 방법에서 분석되는 커널들 간의 데이터 재사용이 가능하도록 재사용될 데이터를 공유 메모리에 캐싱하기 위한 코드를 예시한 모식도이다.8 is a schematic diagram illustrating a code for caching data to be reused in a shared memory so that data can be reused between kernels analyzed in a general-purpose application analysis and optimization method according to an embodiment of the present invention.

도 8을 참조하면, 소스 코드는 커널이 어떤 데이터 그룹을 최초로 사용할 ㄸ때에, 재사용될 데이터 그룹을 공유 메모리에 저장하는 구문을 더 포함하도록 수정될 수 있다. Referring to FIG. 8, the source code may be modified to include a syntax for storing the data group to be reused in the shared memory when the kernel first uses a certain data group.

도 9는 본 발명의 실시예에 따른 범용 어플리케이션 분석 및 최적화 장치를 예시한 블록도이다.9 is a block diagram illustrating a general-purpose application analysis and optimization apparatus according to an embodiment of the present invention.

도 9를 참조하면, 범용 어플리케이션 분석 및 최적화 장치(90)는 공유 메모리를 가지는 그래픽 프로세서 상에서 구동되는 범용 어플리케이션의 소스 코드를 최적화할 수 있다. Referring to FIG. 9, the general purpose application analysis and optimization apparatus 90 can optimize the source code of a general purpose application running on a graphic processor having a shared memory.

이를 위해 범용 어플리케이션 분석 및 최적화 장치(90)는 그래픽 프로세서 에뮬레이터(91), 메모리 접근 기록 생성부(92), 재사용 스택 생성부(93), 재사용 패턴 분석부(94) 및 소스 코드 수정부(95)를 포함할 수 있다.The general application analysis and optimization apparatus 90 includes a graphic processor emulator 91, a memory access record generating unit 92, a reuse stack generating unit 93, a reuse pattern analyzing unit 94 and a source code correcting unit 95 ).

도 9에서 범용 어플리케이션 분석 및 최적화 장치(90)는 CUDA 프로그램 모델을 기초로 예시되었지만, OpenCL과 같은 다른 GPGPU 프로그램 모델도 이와 유사한 구조를 가진다.In FIG. 9, the general-purpose application analysis and optimization apparatus 90 is illustrated based on the CUDA program model, but other GPGPU program models such as OpenCL have a similar structure.

그래픽 프로세서 에뮬레이터(91)는 그래픽 프로세서 장치(96)가 장착된 호스트 시스템(97) 상에서 구동하는 명령어 기반의 그래픽 프로세서 에뮬레이션 프레임워크로서, 그래픽 프로세서 장치(96)와 범용 어플리케이션 사이의 런타임 API를 대체하여, 그래픽 프로세서에서 어플리케이션이 구동될 때에 동적 분석 기능의 일환으로서 전역 메모리 접근을 추적할 수 있다.The graphics processor emulator 91 is an instruction based graphics processor emulation framework that runs on the host system 97 on which the graphics processor device 96 is mounted and replaces the runtime API between the graphics processor device 96 and the general purpose application , Global memory access can be tracked as part of the dynamic analysis function when the application is running on the graphics processor.

그래픽 프로세서 장치(96)는 복수의 스트리밍 멀티프로세서들(961)과 전역 메모리(962)를 포함하며, 스트리밍 멀티프로세서들(961)의 각각은 복수의 코어들과 하나의 공유 메모리를 포함할 수 있다. 복수의 코어들은 각각 쓰레드들을 실행할 수 있고, 하나의 스트리밍 멀티프로세서(961)에 할당되는 쓰레드들은 공유 메모리에 함께 접근할 수 있도록 하나의 쓰레드블록을 구성하는 쓰레드들이다.The graphics processor device 96 includes a plurality of streaming multiprocessors 961 and a global memory 962 and each of the streaming multiprocessors 961 may include a plurality of cores and a shared memory . The plurality of cores can execute threads, respectively, and the threads allocated to one streaming multiprocessor 961 are threads constituting one thread block so that they can access the shared memory together.

그래픽 프로세서 에뮬레이터(91)는 GPGPU 프로그래밍 모델에 따라 프로그래밍된 범용 어플리케이션을 그래픽 프로세서 장치(96)에서 구동시킬 수 있고 한편으로 범용 어플리케이션의 구동 시에 이벤트 발생 추적, 스케줄링, 자원 분배 등을 수행할 수 있다. The graphics processor emulator 91 can drive a general purpose application programmed in accordance with the GPGPU programming model with the graphics processor device 96 and can perform event generation tracking, scheduling, resource allocation, and the like when running a general purpose application .

최적화 전의 어플리케이션이 그래픽 프로세서 에뮬레이터(91) 상에서 구동되면서 그래픽 프로세서 에뮬레이터(91)에 의해 전역 메모리 접근이 모니터링되면, 메모리 접근 기록 생성부(92)는, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성할 수 있다.When the application before optimization is driven on the graphic processor emulator 91 and the global memory access is monitored by the graphic processor emulator 91, the memory access record generating unit 92 generates the thread information of the thread causing the global memory access and the data index To generate a memory access record.

실시예에 따라, 메모리 접근 기록은 커널 정보를 더 포함할 수 있다.According to an embodiment, the memory access record may further include kernel information.

재사용 스택 생성부(93)는, 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성할 수 있다.When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, the reuse stack generating unit 93 generates a plurality of reusable stacks by grouping at least one data accessed by threads belonging to each thread group The re-use stack can be created for each thread group.

실시예에 따라, 쓰레드 그룹은 커널, 그리드 및 블록 중 하나일 수 있다.According to an embodiment, the thread group may be one of a kernel, a grid, and a block.

재사용 패턴 분석부(94)는 메모리 접근 기록 및 재사용 스택 중 적어도 하나에 기초하여, 데이터 그룹들의 재사용 패턴을 분석할 수 있다.The reuse pattern analysis unit 94 may analyze a reuse pattern of data groups based on at least one of a memory access record and a reuse stack.

실시예에 따라, 재사용 패턴은 재사용 스택에 기초하여 분석되며, 각 데이터 그룹의 재사용 거리일 수 있다.According to an embodiment, the reuse pattern is analyzed based on the reuse stack, and may be the reuse distance of each data group.

실시예에 따라, 재사용 패턴은 메모리 접근 기록 및 재사용 스택에 기초하여 분석되며, 전역 메모리 접근을 일으키는 코드가 실행될 때 접근되는 데이터들의 개수에 대한, 데이터들에 접근하는 쓰레드들의 개수의 비로 정의되는 쓰레드 밀도일 수 있다.According to an embodiment, the reuse pattern is analyzed based on the memory access record and reuse stack, and a thread defined as a ratio of the number of threads accessing data to the number of data accessed when the code causing global memory access is executed Density.

실시예에 따라, 재사용 패턴은 재사용 거리와 쓰레드 밀도를 모두 포함할 수 있다.According to an embodiment, the reuse pattern may include both the reuse distance and the thread density.

실시예에 따라, 재사용 패턴은, 각 커널마다 재사용 스택에 기초하여 분석되며, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리일 수 있다.According to an embodiment, the reuse pattern may be a reuse distance of each of the data groups that are analyzed based on the reuse stack for each kernel and accessed more than once by threads belonging to the kernel.

소스 코드 수정부(95)는 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터에 관하여, 데이터를 공유 메모리에 저장하는 코드를 가지도록 어플리케이션의 소스 코드를 수정할 수 있다.The source code modification unit 95 can modify the source code of the application so as to have the code for storing the data in the shared memory with respect to the data identified as being reused based on the reuse pattern.

실시예에 따라, 소스 코드 수정부(95)는, 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별할 수 있다.According to the embodiment, the source code correcting unit 95 can identify the reuse data and reused data, respectively, based on the reuse distance.

이 경우에, 소스 코드 수정부(95)는 재사용될 데이터를 식별된 쓰레드의 시작 후에 공유 메모리에 저장하는 구문 및 식별된 쓰레드가 실행되는 동안에 식별된 쓰레드가 식별된 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정할 수 있다.In this case, the source code modification unit 95 has a syntax for storing the data to be reused in the shared memory after the start of the identified thread, and a syntax for accessing the identified data in the shared memory while the identified thread is being executed You can modify the source code to have

실시예에 따라, 소스 코드 수정부(95)는, 쓰레드 밀도가 소정의 문턱값, 예를 들어 1보다 크면, 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별할 수 있다.According to the embodiment, the source code correcting unit 95 can identify each of the threads accessing the global memory and reused data by an instruction if the thread density is greater than a predetermined threshold value, for example, 1.

이 경우에, 소스 코드 수정부(95)는 재사용되는 데이터들을 식별된 쓰레드들의 시작 후에 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 식별된 쓰레드들을 실행되는 동안에 식별된 쓰레드들이 식별된 데이터들을 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정할 수 있다.In this case, the source code modifier 95 may be configured to store the reused data in the shared memory after the start of the identified threads, the syntax to synchronize the threads, and the identities of the identified threads during execution of the identified threads You can modify the source code so that it has syntax to access from shared memory.

실시예에 따라, 소스 코드 수정부(95)는, 쓰레드 밀도가 소정의 문턱값, 예를 들어 1보다 작으면, 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별할 수 있다.According to the embodiment, the source code correcting unit 95 may be configured so that, when the thread density is smaller than a predetermined threshold value, for example, 1, the threads reusing data among threads accessing the global memory by an instruction, Data can be individually identified.

이 경우에, 소스 코드 수정부(95)는 재사용되는 데이터들을 식별된 쓰레드들의 시작 시에 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 식별된 쓰레드들을 실행되는 동안에 식별된 쓰레드들이 식별된 데이터들을 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정할 수 있다.In this case, the source code modifier 95 includes a syntax for storing the reused data in the shared memory at the start of the identified threads, a syntax for synchronizing the threads, and for identifying the identified threads You can modify the source code to have the syntax to access them from shared memory.

한편, 실시예에 따라, 소스 코드 수정부(95)는 재사용 거리와 쓰레드 밀도를 함께 고려할 수 있다.On the other hand, according to the embodiment, the source code correcting unit 95 can consider both the reuse distance and the thread density.

구체적으로, 소스 코드 수정부(95)는 재사용 거리가 제1 문턱값보다 클 때에 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하거나, 쓰레드 밀도가 제2 문턱값보다 클 때에 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별할 수 있다.Specifically, when the reuse distance is greater than the first threshold value, the source code correcting unit 95 identifies the reuse data and reused data on the basis of the reuse distance, respectively, or if the thread density is smaller than the second threshold value When it is large, it is possible to identify each thread accessing global memory and reused data by an instruction.

이 경우에, 소스 코드 수정부(95)는 식별된 쓰레드와 데이터에 관하여, 재사용되는 데이터를 식별된 쓰레드의 시작 후에 공유 메모리에 저장하는 구문, 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에는 쓰레드들을 동기화하는 구문 및 식별된 쓰레드가 실행되는 동안에 식별된 쓰레드가 식별된 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정할 수 있다.In this case, the source code modifier 95 is configured to store, in relation to the identified thread and data, the syntax for storing the reused data in the shared memory after the start of the identified thread; if the reused data is reused between the threads, And to modify the source code so that the identified thread during execution of the identified thread has the syntax to access the identified data from the shared memory.

실시예에 따라, 쓰레드 그룹이 커널이면, 소스 코드 수정부(95)는, 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별할 수 있다.According to the embodiment, if the thread group is a kernel, the source code correcting unit 95 can identify the reuse data and the reused data, respectively, based on the reuse distance.

이 경우에, 소스 코드 수정부(95)는 식별된 쓰레드와 데이터에 관하여, 식별된 쓰레드를 포함하는 커널의 시작 후에 재사용되는 데이터를 공유 메모리에 저장하는 구문과 식별된 쓰레드가 실행되는 동안에 식별된 쓰레드가 식별된 데이터를 공유 메모리에서 접근하는 구문을 가지도록 소스 코드를 수정할 수 있다.In this case, the source code modification unit 95 determines, with respect to the identified thread and data, the syntax for storing the reused data in the shared memory after the start of the kernel including the identified thread, The source code can be modified so that the thread has the syntax to access the identified data from the shared memory.

본 실시예 및 본 명세서에 첨부된 도면은 본 발명에 포함되는 기술적 사상의 일부를 명확하게 나타내고 있는 것에 불과하며, 본 발명의 명세서 및 도면에 포함된 기술적 사상의 범위 내에서 당업자가 용이하게 유추할 수 있는 변형예와 구체적인 실시예는 모두 본 발명의 권리범위에 포함되는 것이 자명하다고 할 것이다.It is to be understood that both the foregoing general description and the following detailed description of the present invention are exemplary and explanatory and are intended to provide further explanation of the invention as claimed. It will be understood that variations and specific embodiments which may occur to those skilled in the art are included within the scope of the present invention.

또한, 본 발명에 따른 장치는 컴퓨터로 읽을 수 있는 기록매체에 컴퓨터가 읽을 수 있는 코드로서 구현하는 것이 가능하다. 컴퓨터가 읽을 수 있는 기록매체는 컴퓨터 시스템에 의하여 읽힐 수 있는 데이터가 저장되는 모든 종류의 기록장치를 포함한다. 기록매체의 예로는 ROM, RAM, 광학 디스크, 자기 테이프, 플로피 디스크, 하드 디스크, 비휘발성 메모리 등을 포함한다. 또한 컴퓨터가 읽을 수 있는 기록매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어 분산방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수 있다.Further, the apparatus according to the present invention can be implemented as a computer-readable code on a computer-readable recording medium. A computer-readable recording medium includes all kinds of recording apparatuses in which data that can be read by a computer system is stored. Examples of the recording medium include ROM, RAM, optical disk, magnetic tape, floppy disk, hard disk, nonvolatile memory and the like. The computer-readable recording medium may also be distributed over a networked computer system so that computer readable code can be stored and executed in a distributed manner.

90 범용 어플리케이션 분석 및 최적화 장치
91 그래픽 프로세서 에뮬레이터
92 메모리 접근 기록 생성부
93 재사용 스택 생성부
94 재사용 패턴 분석부
95 소스 코드 수정부
96 그래픽 프로세서 장치
961 스트리밍 멀티프로세서
962 전역 메모리
97 호스트 시스템
90 General purpose application analysis and optimization device
91 Graphics Processor Emulator
92 Memory access record generation unit
93 Reuse stack generating part
94 Reuse Pattern Analysis Unit
95 Source Code Correction
96 graphics processor unit
961 Streaming Multiprocessor
962 Global memory
97 Host systems

Claims (22)

컴퓨터를 이용하여 그래픽 프로세서 상에서 범용 어플리케이션의 구동을 분석하는 범용 어플리케이션 분석 방법으로서,
상기 컴퓨터가,
그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 어플리케이션의 전역(global) 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계;
상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 단계; 및
상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 단계를 포함하는 범용 어플리케이션 분석 방법으로,
상기 쓰레드 그룹은 커널이고,
상기 메모리 접근 기록은 커널 정보, 쓰레드 정보 및 데이터 인덱스를 포함하도록 생성되는 것을 특징으로 하는 범용 어플리케이션 분석 방법.
A general purpose application analysis method for analyzing the operation of a general purpose application on a graphic processor using a computer,
The computer comprising:
Generating a memory access record by recording thread information and a data index of a thread causing a global memory access while monitoring a global memory access of an application before optimization executed on the graphics processor emulator;
When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, Creating a reuse stack for each thread group; And
Analyzing a reuse pattern of data groups based on the reuse stack, the method comprising:
The thread group is a kernel,
Wherein the memory access record is generated to include kernel information, thread information, and a data index.
청구항 1에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션 분석 방법.
The method of claim 1, wherein analyzing the reuse pattern
And calculating a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once based on the reuse stack for each thread group.
청구항 1에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되는 것을 특징으로 하는 범용 어플리케이션 분석 방법.
The method of claim 1, wherein analyzing the reuse pattern
For each thread group, calculating thread density based on the memory access record and the reuse stack of the thread group,
Wherein the thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing the global memory access, .
삭제delete 컴퓨터에서 청구항 1 내지 청구항 3 중 어느 한 청구항에 따른 범용 어플리케이션 분석 방법의 각 단계들을 구현할 수 있도록 작성되어 컴퓨터로 독출가능한 비일시적 기록 매체에 기록된 컴퓨터 프로그램.A computer program recorded on a non-transitory recording medium readable by a computer so as to be able to implement the steps of the general-purpose application analysis method according to any one of claims 1 to 3. 컴퓨터를 이용하여, 공유 메모리를 가지는 그래픽 프로세서 상에서 범용 어플리케이션의 소스 코드를 최적화하는 범용 어플리케이션 최적화 방법으로서,
상기 컴퓨터가,
그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계;
상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 단계;
상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 단계; 및
상기 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터에 관하여, 상기 데이터를 상기 공유 메모리에 저장하는 코드를 가지도록 상기 범용 어플리케이션의 소스 코드를 수정하는 단계를 포함하는 범용 어플리케이션의 소스 코드 최적화 방법.
A general-purpose application optimization method for optimizing a source code of a general-purpose application on a graphic processor having a shared memory using a computer,
The computer comprising:
Generating a memory access record by recording thread information and a data index of a thread causing a global memory access while monitoring a global memory access of a non-optimization general application running on a graphics processor emulator;
When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, Creating a reuse stack for each thread group;
Analyzing a reuse pattern of data groups based on the reuse stack; And
And modifying the source code of the general purpose application to have code for storing the data in the shared memory with respect to data identified as being reused based on the reuse pattern.
청구항 6에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함하고,
상기 범용 어플리케이션의 소스 코드를 수정하는 단계는
상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계; 및
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 방법.
The method of claim 6, wherein analyzing the reuse pattern
Calculating a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once based on the reuse stack for each thread group,
The step of modifying the source code of the general purpose application
Identifying a reuse thread and reused data, respectively, based on the reuse distance; And
The method comprising: for the identified thread and data, a statement for storing the reused data in the shared memory after the start of the identified thread, and for executing the identified thread while the identified thread is executing the identified data in the shared memory And modifying the source code to have a syntax for accessing the source code.
청구항 6에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 범용 어플리케이션의 소스 코드를 수정하는 단계는
상기 쓰레드 밀도가 1보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및
상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 후에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 방법.
The method of claim 6, wherein analyzing the reuse pattern
For each thread group, calculating thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The step of modifying the source code of the general purpose application
Identifying threads that access the global memory and reused data by the instruction if the thread density is greater than one; And
Wherein the identified threads and data are stored in the shared memory after the start of the identified threads, the syntax for synchronizing threads, and the syntax for synchronizing the identified threads with the identified threads And modifying the source code to have a syntax for accessing the identified data in the shared memory.
청구항 6에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 범용 어플리케이션의 소스 코드를 수정하는 단계는
상기 쓰레드 밀도가 1보다 작으면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및
상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 시에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 방법.
The method of claim 6, wherein analyzing the reuse pattern
For each thread group, calculating thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The step of modifying the source code of the general purpose application
Identifying threads for reusing data and reused data among threads accessing the global memory by the instruction if the thread density is less than 1; And
Wherein the identified threads and data are stored in the shared memory at the start of the identified threads, the syntax for synchronizing threads, and the syntax for synchronizing threads during execution of the identified threads And modifying the source code so that the source code has a syntax for accessing the identified data in the shared memory.
청구항 6에 있어서, 상기 재사용 패턴을 분석하는 단계는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계; 및
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하는 단계를 포함하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 범용 어플리케이션의 소스 코드를 수정하는 단계는
상기 재사용 거리가 제1 문턱값보다 클 때에 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계;
상기 쓰레드 밀도가 제2 문턱값보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하는 단계; 및
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문, 상기 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 방법.
The method of claim 6, wherein analyzing the reuse pattern
Calculating reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once based on the reuse stack for each thread group; And
For each thread group, calculating thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The step of modifying the source code of the general purpose application
Identifying a reuse thread and reused data, respectively, based on the reuse distance when the reuse distance is greater than a first threshold value;
Identifying threads accessing the global memory and reused data by the instruction if the thread density is greater than a second threshold; And
A statement to store, in relation to the identified thread and data, the reused data in the shared memory after the start of the identified thread; a statement to synchronize threads when the reused data is reused between threads; And modifying the source code so that the identified thread has a syntax for accessing the identified data in the shared memory while the thread is being executed.
청구항 6에 있어서, 상기 쓰레드 그룹은 커널이고,
상기 메모리 접근 기록을 생성하는 단계는
전역 메모리 접근을 일으키는 쓰레드의 커널 정보, 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 단계를 포함하고,
상기 재사용 패턴을 분석하는 단계는
각 커널마다, 상기 재사용 스택에 기초하여, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하는 단계를 포함하고,
상기 범용 어플리케이션의 소스 코드를 수정하는 단계는
상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하는 단계; 및
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드를 포함하는 커널의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문과 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하는 단계를 포함하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 방법.
7. The method of claim 6, wherein the thread group is a kernel,
Wherein the generating the memory access record comprises:
Generating a memory access record by recording kernel information, thread information and a data index of a thread causing a global memory access,
The step of analyzing the reuse pattern
Calculating reuse distance of each of the data groups accessed by the threads belonging to the kernel more than once based on the reuse stack for each kernel,
The step of modifying the source code of the general purpose application
Identifying a reuse thread and reused data, respectively, based on the reuse distance; And
Wherein the identified thread and the data are stored in the shared memory after the start of the kernel including the identified thread and the identified thread is executing the identified data during execution of the identified thread And modifying the source code to have a syntax for accessing from the shared memory.
컴퓨터에서 청구항 6 내지 청구항 11 중 어느 한 청구항에 따른 범용 어플리케이션의 소스 코드 최적화 방법의 각 단계들을 구현할 수 있도록 작성되어 컴퓨터로 독출가능한 비일시적 기록 매체에 기록된 컴퓨터 프로그램.A computer program recorded on a computer-readable non-volatile recording medium so as to be able to implement each step of a source code optimization method of a general purpose application according to any one of claims 6 to 11 in a computer. 그래픽 프로세서 상에서 범용 어플리케이션의 구동을 분석하는 범용 어플리케이션 분석 장치로서,
그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 메모리 접근 기록 생성부;
상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 재사용 스택 생성부; 및
상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 재사용 패턴 분석부를 포함하는 범용 어플리케이션 분석 장치로서,
상기 쓰레드 그룹은 커널이고,
상기 메모리 접근 기록은 커널 정보, 쓰레드 정보 및 데이터 인덱스를 포함하도록 생성되는 것을 특징으로 하는 범용 어플리케이션 분석 장치.
A general purpose application analyzing apparatus for analyzing the operation of a general purpose application on a graphic processor,
A memory access record generating unit for generating a memory access record by recording thread information and a data index of a thread causing a global memory access while monitoring a global memory access of a non-optimization general application running on a graphics processor emulator;
When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, A reusable stack generating unit for generating a reusable stack for each thread group; And
And a reuse pattern analyzer for analyzing a reuse pattern of data groups based on the reuse stack, the apparatus comprising:
The thread group is a kernel,
Wherein the memory access record is generated to include kernel information, thread information, and a data index.
청구항 13에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작하는 것을 특징으로 하는 범용 어플리케이션 분석 장치.
14. The apparatus of claim 13, wherein the reuse pattern analyzer
And for each thread group to calculate a reuse distance of each of the data groups accessed more than once by threads belonging to the thread group based on the reuse stack.
청구항 13에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되는 것을 특징으로 하는 범용 어플리케이션 분석 장치.
14. The apparatus of claim 13, wherein the reuse pattern analyzer
For each thread group, to calculate a thread density based on the memory access record and the reuse stack of the thread group,
Wherein the thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing the global memory access, .
삭제delete 공유 메모리를 가지는 그래픽 프로세서 상에서 범용 어플리케이션의 소스 코드를 최적화하는 범용 어플리케이션 최적화 장치로서,
그래픽 프로세서 에뮬레이터 상에서 구동되는 최적화 전의 범용 어플리케이션의 전역 메모리 접근을 모니터링하면서, 전역 메모리 접근을 일으키는 쓰레드의 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하는 메모리 접근 기록 생성부;
상기 메모리 접근 기록에 기록된 복수의 쓰레드들이 복수의 쓰레드 그룹들을 구성할 경우에, 각 쓰레드 그룹마다 각 쓰레드 그룹에 속하는 쓰레드들이 접근하는 적어도 하나의 데이터를 군집화한 복수의 데이터 그룹들을 접근된 순서대로 나열하여, 각 쓰레드 그룹마다 재사용 스택을 생성하는 재사용 스택 생성부;
상기 재사용 스택에 기초하여, 데이터 그룹들의 재사용 패턴을 분석하는 재사용 패턴 분석부; 및
상기 재사용 패턴에 기초하여 재사용되는 것으로 식별된 데이터에 관하여, 상기 데이터를 상기 공유 메모리에 저장하는 코드를 가지도록 상기 범용 어플리케이션의 소스 코드를 수정하는 소스 코드 수정부를 포함하는 범용 어플리케이션의 소스 코드 최적화 장치.
A general-purpose application optimizing apparatus for optimizing a source code of a general-purpose application on a graphic processor having a shared memory,
A memory access record generating unit for generating a memory access record by recording thread information and a data index of a thread causing a global memory access while monitoring a global memory access of a non-optimization general application running on a graphics processor emulator;
When a plurality of threads recorded in the memory access record constitute a plurality of thread groups, a plurality of data groups, which are groups of at least one data accessed by threads belonging to each thread group, A reusable stack generating unit for generating a reusable stack for each thread group;
A reuse pattern analyzer for analyzing a reuse pattern of data groups based on the reuse stack; And
And a source code modifying unit for modifying the source code of the general purpose application so as to have a code for storing the data in the shared memory with respect to data identified as being reused based on the reuse pattern, .
청구항 17에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작하고,
상기 소스 코드 수정부는
상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하고,
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 장치.
18. The apparatus of claim 17, wherein the reuse pattern analyzer
For each thread group, to calculate a reuse distance of each of the data groups accessed more than once by threads belonging to the thread group, based on the reuse stack,
The source code modification unit
Based on the reuse distance, identifying a thread for reusing data and reusing data, respectively,
The method comprising: for the identified thread and data, a statement for storing the reused data in the shared memory after the start of the identified thread, and for executing the identified thread while the identified thread is executing the identified data in the shared memory And to modify the source code to have a syntax for accessing the source code.
청구항 17에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 소스 코드 수정부는
상기 쓰레드 밀도가 1보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하고,
상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 후에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정도록 동작하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 장치.
18. The apparatus of claim 17, wherein the reuse pattern analyzer
For each thread group, to calculate a thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The source code modification unit
If the thread density is greater than 1, identify threads accessing the global memory and reused data by the instruction,
Wherein the identified threads and data are stored in the shared memory after the start of the identified threads, the syntax for synchronizing threads, and the syntax for synchronizing the identified threads with the identified threads And to modify the source code so as to have a syntax for accessing the identified data in the shared memory.
청구항 17에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하고,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 소스 코드 수정부는
상기 쓰레드 밀도가 1보다 작으면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 중 데이터를 재사용하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하고,
상기 식별된 쓰레드들과 데이터들에 관하여, 상기 식별된 쓰레드들의 시작 시에 상기 재사용되는 데이터들을 상기 공유 메모리에 저장하는 구문, 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드들을 실행되는 동안에 상기 식별된 쓰레드들이 상기 식별된 데이터들을 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 장치.
18. The apparatus of claim 17, wherein the reuse pattern analyzer
For each thread group, to calculate a thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The source code modification unit
If the thread density is less than 1, identifies threads for reusing data and reused data among threads accessing the global memory by the instruction,
Wherein the identified threads and data are stored in the shared memory at the start of the identified threads, the syntax for synchronizing threads, and the syntax for synchronizing threads during execution of the identified threads Are operable to modify the source code to have a syntax for accessing the identified data in the shared memory.
청구항 17에 있어서, 상기 재사용 패턴 분석부는
각 쓰레드 그룹마다, 상기 재사용 스택에 기초하여, 해당 쓰레드 그룹에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하고,
각 쓰레드 그룹마다, 해당 쓰레드 그룹의 상기 메모리 접근 기록 및 상기 재사용 스택에 기초하여 쓰레드 밀도를 산출하도록 동작하며,
상기 쓰레드 밀도는, 전역 메모리 접근을 일으키는 하나의 명령어에 의해 전역 메모리에서 접근된 데이터들의 개수에 대한, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들의 개수의 비로 정의되며,
상기 소스 코드 수정부는
상기 재사용 거리가 제1 문턱값보다 클 때에 상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하고,
상기 쓰레드 밀도가 제2 문턱값보다 크면, 상기 명령어에 의해 전역 메모리에 접근하는 쓰레드들 및 재사용되는 데이터들을 각각 식별하며,
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문, 상기 재사용되는 데이터가 쓰레드들 사이에 재사용되는 경우에 쓰레드들을 동기화하는 구문 및 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 장치.
18. The apparatus of claim 17, wherein the reuse pattern analyzer
Calculating a reuse distance of each of the data groups accessed by the threads belonging to the thread group more than once based on the reuse stack for each thread group,
For each thread group, to calculate a thread density based on the memory access record and the reuse stack of the thread group,
The thread density is defined as a ratio of the number of threads accessing the global memory by the instruction to the number of data accessed in the global memory by one instruction causing a global memory access,
The source code modification unit
Identifies a reuse thread and reused data based on the reuse distance when the reuse distance is greater than a first threshold value,
If the thread density is greater than a second threshold value, identifies threads accessing the global memory and reused data by the instruction,
A statement to store, in relation to the identified thread and data, the reused data in the shared memory after the start of the identified thread; a statement to synchronize threads when the reused data is reused between threads; And to modify the source code so that the identified thread has a syntax for accessing the identified data in the shared memory while the thread is being executed.
청구항 17에 있어서, 상기 쓰레드 그룹은 커널이고,
상기 메모리 접근 기록 생성부는
전역 메모리 접근을 일으키는 쓰레드의 커널 정보, 쓰레드 정보 및 데이터 인덱스를 기록하여 메모리 접근 기록을 생성하도록 동작하며,
상기 재사용 패턴 분석부는
각 커널마다, 상기 재사용 스택에 기초하여, 해당 커널에 속하는 쓰레드들에 의해 2회 이상 접근된 데이터 그룹들 각각의 재사용 거리를 산출하도록 동작하고,
상기 소스 코드 수정부는
상기 재사용 거리에 기초하여, 데이터를 재사용하는 쓰레드와 재사용되는 데이터를 각각 식별하며,
식별된 쓰레드와 데이터에 관하여, 상기 식별된 쓰레드를 포함하는 커널의 시작 후에 상기 재사용되는 데이터를 상기 공유 메모리에 저장하는 구문과 상기 식별된 쓰레드가 실행되는 동안에 상기 식별된 쓰레드가 상기 식별된 데이터를 상기 공유 메모리에서 접근하는 구문을 가지도록 상기 소스 코드를 수정하도록 동작하는 것을 특징으로 하는 범용 어플리케이션의 소스 코드 최적화 장치.
18. The system of claim 17, wherein the thread group is a kernel,
The memory access record generating unit
Thread information and a data index of the thread causing the global memory access to generate a memory access record,
The reuse pattern analysis unit
For each kernel, to calculate a reuse distance of each of the data groups accessed more than once by threads belonging to the kernel, based on the reuse stack,
The source code modification unit
Based on the reuse distance, identifies a reuse thread and reused data,
Wherein the identified thread and the data are stored in the shared memory after the start of the kernel including the identified thread and the identified thread is executing the identified data during execution of the identified thread And to modify the source code to have a syntax for accessing from the shared memory.
KR1020150144800A 2015-10-16 2015-10-16 Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units KR101752062B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020150144800A KR101752062B1 (en) 2015-10-16 2015-10-16 Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020150144800A KR101752062B1 (en) 2015-10-16 2015-10-16 Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units

Publications (2)

Publication Number Publication Date
KR20170045437A KR20170045437A (en) 2017-04-27
KR101752062B1 true KR101752062B1 (en) 2017-07-03

Family

ID=58702641

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020150144800A KR101752062B1 (en) 2015-10-16 2015-10-16 Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units

Country Status (1)

Country Link
KR (1) KR101752062B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11036559B2 (en) 2018-11-06 2021-06-15 Samsung Electronics Co., Ltd. Graphics processor and graphics processing method based on subdivided states

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102323276B1 (en) * 2021-03-18 2021-11-05 세종대학교산학협력단 Method and apparatus for converting application

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101101992B1 (en) * 2010-04-30 2012-01-13 광운대학교 산학협력단 Method and apparatus of optimal application mapping on coarse-grained reconfigurable array

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101101992B1 (en) * 2010-04-30 2012-01-13 광운대학교 산학협력단 Method and apparatus of optimal application mapping on coarse-grained reconfigurable array

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11036559B2 (en) 2018-11-06 2021-06-15 Samsung Electronics Co., Ltd. Graphics processor and graphics processing method based on subdivided states

Also Published As

Publication number Publication date
KR20170045437A (en) 2017-04-27

Similar Documents

Publication Publication Date Title
US11847508B2 (en) Convergence among concurrently executing threads
Wahib et al. Scalable kernel fusion for memory-bound GPU applications
US9678775B1 (en) Allocating memory for local variables of a multi-threaded program for execution in a single-threaded environment
US20140149719A1 (en) Arithmetic processing apparatus, control method of arithmetic processing apparatus, and a computer-readable storage medium storing a control program for controlling an arithmetic processing apparatus
JP2020518881A (en) Computer-implemented method, computer-readable medium and heterogeneous computing system
US10318261B2 (en) Execution of complex recursive algorithms
US8615770B1 (en) System and method for dynamically spawning thread blocks within multi-threaded processing systems
CN112148472A (en) Method and apparatus for improving utilization of heterogeneous system executing software
Edelkamp et al. Efficient explicit-state model checking on general purpose graphics processors
KR101752062B1 (en) Apparatus and method for analyzing general application to be operative upon general-purpose graphic processing units
US10296671B2 (en) Method of and apparatus for performing simulation using plurality of processors in parallel
US20110102441A1 (en) Characteristic determination for an output node
WO2022118079A1 (en) Methods, computer programs and devices for detecting potential race conditions
US20140196016A1 (en) Layered programming for heterogeneous devices
Connors et al. Automatically selecting profitable thread block sizes for accelerated kernels
US8806466B2 (en) Program generation device, program production method, and program
US9081560B2 (en) Code tracing processor selection
Laurenzano et al. A static binary instrumentation threading model for fast memory trace collection
Lotrič et al. Parallel implementations of recurrent neural network learning
Yamashita et al. Bulk execution of the dynamic programming for the optimal polygon triangulation problem on the GPU
Wozniak et al. Parallel implementation of conjugate gradient method on graphics processors
Allen Improving real-time performance with CUDA persistent threads (CuPer) on the Jetson TX2
US20240169200A1 (en) Profiling-based job ordering for distributed deep learning
US9552197B2 (en) Computer-readable recording medium storing information processing program, information processing apparatus, and information processing method
US11567745B2 (en) Compiler adapted in graphics processing unit and non-transitory computer-readable medium

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant
FPAY Annual fee payment

Payment date: 20200217

Year of fee payment: 4