KR102267500B1 - Idempotent kernel generateing method and apparatus - Google Patents

Idempotent kernel generateing method and apparatus Download PDF

Info

Publication number
KR102267500B1
KR102267500B1 KR1020200130289A KR20200130289A KR102267500B1 KR 102267500 B1 KR102267500 B1 KR 102267500B1 KR 1020200130289 A KR1020200130289 A KR 1020200130289A KR 20200130289 A KR20200130289 A KR 20200130289A KR 102267500 B1 KR102267500 B1 KR 102267500B1
Authority
KR
South Korea
Prior art keywords
variable
kernel
access
idempotent
code
Prior art date
Application number
KR1020200130289A
Other languages
Korean (ko)
Other versions
KR20200140210A (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
Priority claimed from KR1020190066832A external-priority patent/KR102201669B1/en
Application filed by 성균관대학교산학협력단, 재단법인 초고성능 컴퓨팅 연구단 filed Critical 성균관대학교산학협력단
Priority to KR1020200130289A priority Critical patent/KR102267500B1/en
Publication of KR20200140210A publication Critical patent/KR20200140210A/en
Application granted granted Critical
Publication of KR102267500B1 publication Critical patent/KR102267500B1/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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3824Operand accessing
    • G06F9/3834Maintaining memory consistency
    • 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/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Storage Device Security (AREA)

Abstract

본 명세서는 멱등 커널 생성 방법 및 장치를 개시한다. 구체적으로, 본 발명의 일 실시 예에 따른 멱등 커널 생성 방법은 분석부의 제어 하에 GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인하는 단계; 코드 삽입부의 제어 하에 제1 메모리 변수에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입하는 단계; 변수 선언부의 제어 하에 상기 GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 제1 메모리 변수로 초기화하는 단계; 및 결정 코드 삽입부의 제어 하에 상기 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 상기 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입하는 단계를 포함한다.The present specification discloses a method and apparatus for generating an idempotent kernel. Specifically, the method for generating an idempotent kernel according to an embodiment of the present invention includes the steps of checking a first memory variable related to a write after read (WAR) risk that is not statically determined in the source code related to the GPU kernel function under the control of the analysis unit ; inserting a code for setting an access flag bitmap for tracking read access or write access to the first memory variable under the control of the code inserting unit; declaring a temporary pointer variable in the GPU kernel function as a local variable under the control of a variable declaration unit and initializing it as a first memory variable; and inserting a code for dynamically determining whether the temporary pointer variable is a first memory variable or a second memory variable after a read access to the temporary pointer variable under the control of the decision code inserting unit and before a write access occurs. do.

Figure 112020106661837-pat00005
Figure 112020106661837-pat00005

Description

멱등(IDEMPOTENT) 커널 생성 방법 및 장치{IDEMPOTENT KERNEL GENERATEING METHOD AND APPARATUS}IDEMPOTENT KERNEL GENERATEING METHOD AND APPARATUS

본 명세서는 멱등 커널 생성에 관한 것으로서, 상세하게는 GPU의 중단에 의한 데이터 하자드의 발생을 방지하는 방법 및 장치에 관한 것이다.The present specification relates to generation of an idempotent kernel, and more particularly, to a method and apparatus for preventing occurrence of a data hazard due to the interruption of a GPU.

그래픽 처리 장치(Graphics Processing Unit, GPU)는 하드웨어 제약사항으로 인해 선점 기능을 지원하지 않는다. GPU는 중앙 처리 장치(Central Processing Unit, CPU)와 달리 다수의 코어에서 병렬적으로 스레드를 수행하기 때문에 인스트럭션 단위의 컨텍스트 스위치를 위해서는 컨텍스트 저장 및 인출 비용이 크다.The Graphics Processing Unit (GPU) does not support the preemption function due to hardware limitations. Unlike the central processing unit (CPU), the GPU executes threads in parallel on multiple cores, so the cost of saving and retrieving a context is high for a context switch in an instruction unit.

또한, GPU는 선점 스케쥴링을 지원하지 않아 우선순위 역전현상이 발생될 수 있다. 또한, GPU는 이미 실행이 시작된 커널이 있다면, 커널의 실행이 완료될 때 까지 다른 커널로 컨텍스트 스위칭을 할 수 없다. 여기서, 우선순위 역전 문제란 낮은 우선순위 작업 수행으로 인해 높은 우선순위 작업이 실행을 대기하여 실행이 지체되는 현상을 의미한다. 이는 실시간 시스템에서 반드시 해결되어야 하는 문제이다.Also, since the GPU does not support preemptive scheduling, a priority inversion phenomenon may occur. Also, if there is a kernel that has already started to be executed, the GPU cannot perform context switching to another kernel until execution of the kernel is completed. Here, the priority reversal problem refers to a phenomenon in which a high-priority task is waiting for execution due to the execution of a low-priority task and execution is delayed. This is a problem that must be solved in real-time systems.

GPU는 일반적으로 실행중단(abort) 명령을 제공하지만, abort 명령으로 커널의 실행을 중단하면 애플리케이션 전체의 실행이 중단되고 처음부터 다시 실행되어야 한다. 하나의 애플리케이션은 일반적으로 다수의 GPU 커널을 순차적으로 실행하며, 각각의 커널은 이전 수행 커널의 결과에 의존성(dependency)을 갖을 수 있다. 따라서, 임의의 순간에 GPU 커널이 중단될 경우, 커널이 수행 중에 변경한 입력 데이터가 변경되고 현재 이러한 변경된 데이터를 복구할 수단을 GPU 시스템에서 제공하고 있지 않기 때문에, 동일 연산 결과를 가지도록 입력 데이터 초기화를 위해서 애플리케이션 수준에서 재 수행이 이루어져야 할 수 있다. 이러한 GPU 환경에서 선점형 스케줄링을 지원하기 위해서는 GPU 커널 수행 중 변경되는 입력 데이터들에 대한 일관성을 보장하기 위한 기술이 요구된다.The GPU generally provides an abort command, but if the kernel is interrupted with the abort command, the entire application execution is stopped and must be started again from the beginning. One application generally sequentially executes a plurality of GPU kernels, and each kernel may have a dependency on a result of a previously executed kernel. Therefore, if the GPU kernel is stopped at any moment, the input data changed during execution of the kernel is changed, and the GPU system currently does not provide a means for recovering the changed data, so that the input data has the same operation result. Re-execution may be required at the application level for initialization. In order to support preemptive scheduling in such a GPU environment, a technology for ensuring consistency of input data changed during execution of the GPU kernel is required.

본 명세서는 GPU 범용 컴퓨팅 환경에서 애플리케이션 중단 없이 GPU 커널의 중단 및 재수행을 보장하는 방법을 제공함에 목적이 있다.An object of the present specification is to provide a method for ensuring that the GPU kernel is stopped and re-executed without application interruption in a GPU general-purpose computing environment.

또한, 본 명세서는 하드웨어 지원 없이 GPU 커널의 우선 순위에 따른 스케줄링을 지원할 수 있는 방법을 제공함에 목적이 있다.Another object of the present specification is to provide a method capable of supporting scheduling according to the priority of the GPU kernel without hardware support.

또한, 본 명세서는 GPU 커널이 임의 시점에 중단되더라도 데이터 일관성을 보장하며 재수행이 가능한 방법을 제공함에 목적이 있다.In addition, an object of the present specification is to provide a method that guarantees data consistency and can be re-executed even if the GPU kernel is stopped at any time.

본 발명에서 이루고자 하는 기술적 과제들은 이상에서 언급한 기술적 과제들로 제한되지 않으며, 언급하지 않은 또 다른 기술적 과제들은 아래의 기재로부터 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 명확하게 이해될 수 있을 것이다.The technical problems to be achieved in the present invention are not limited to the technical problems mentioned above, and other technical problems not mentioned will be clearly understood by those of ordinary skill in the art to which the present invention belongs from the following description. will be able

본 발명의 일 실시 예에 따른 멱등 커널 생성 방법은, GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인하는 단계와, 상기 제1 메모리 변수들에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입하는 단계와, 상기 GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 상기 제1 메모리 변수로 초기화하는 단계와, 상기 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 상기 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입하는 단계를 포함하는 것을 특징으로 할 수 있다.The method for generating an idempotent kernel according to an embodiment of the present invention includes: identifying a first memory variable related to a write after read (WAR) risk that is not statically determined in a source code related to a GPU kernel function; Inserting a code for setting an access flag bitmap for tracking read access or write access to variables; Declaring a temporary pointer variable in the GPU kernel function as a local variable, and initializing it as the first memory variable and inserting code that dynamically determines whether the temporary pointer variable is a first memory variable or a second memory variable after a read access to the temporary pointer variable and before a write access occurs. can do.

또한, 상기 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 변수들은 조건문 또는 동적으로 결정되는 인덱스와 관련된 변수들일 수 있다.In addition, the variables related to the write after read (WAR) risk that are not statically determined may be variables related to a conditional statement or a dynamically determined index.

또한, 상기 접근 플래그 비트맵은 글로벌 메모리에 포함되는 영역들 각각에 대한 쓰기 접근 또는 읽기 접근을 나타내는 비트(bit) 집합일 수 있다.Also, the access flag bitmap may be a set of bits indicating write access or read access to each of the regions included in the global memory.

또한, 상기 접근 플래그 비트맵을 설정하는 코드는 상기 글로벌 메모리에 포함되는 특정 영역에 읽기 접근 또는 쓰기 접근이 발생한 경우, 상기 특정 영역에 매핑되는 비트가 1의 값을 갖도록 할 수 있다.Also, the code for setting the access flag bitmap may cause a bit mapped to the specific area to have a value of 1 when a read access or a write access occurs to a specific area included in the global memory.

또한, 상기 제1 메모리 변수 및 상기 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.Also, the first memory variable and the second memory variable may be global memory variables.

본 발명의 일 실시 예에 따른 멱등 커널 생성 장치는, GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인하는 분석부와, 상기 제1 메모리 변수에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입하는 플래그 코드 삽입부와, 상기 GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 상기 제1 메모리 변수로 초기화하는 변수 선언부와, 상기 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 상기 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입하는 결정 코드 삽입부를 포함하는 것을 특징으로 할 수 있다.An apparatus for generating an idempotent kernel according to an embodiment of the present invention includes an analysis unit that identifies a first memory variable related to a write after read (WAR) risk that is not statically determined in a source code related to a GPU kernel function, and the first A flag code insertion unit for inserting a code for setting an access flag bitmap for tracking read access or write access to a memory variable, and a temporary pointer variable in the GPU kernel function is declared as a local variable, and the first memory variable and a decision code for inserting code for dynamically determining whether the temporary pointer variable is a first memory variable or a second memory variable after a read access to the temporary pointer variable and before a write access occurs It may be characterized in that it includes an insert.

또한, 상기 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 변수들은 조건문 또는 동적으로 결정되는 인덱스와 관련된 변수들일 수 있다.In addition, the variables related to the write after read (WAR) risk that are not statically determined may be variables related to a conditional statement or a dynamically determined index.

또한, 상기 접근 플래그 비트맵은 글로벌 메모리에 포함되는 영역들 각각에 대한 쓰기 접근 또는 읽기 접근을 나타내는 비트(bit) 집합일 수 있다.Also, the access flag bitmap may be a set of bits indicating write access or read access to each of the regions included in the global memory.

또한, 상기 접근 플래그 비트맵을 설정하는 코드는 상기 글로벌 메모리에 포함되는 특정 영역에 읽기 접근 또는 쓰기 접근이 발생한 경우, 상기 특정 영역에 매핑되는 비트가 1의 값을 갖도록 할 수 있다.Also, the code for setting the access flag bitmap may cause a bit mapped to the specific area to have a value of 1 when a read access or a write access occurs to a specific area included in the global memory.

또한, 상기 제1 메모리 변수 및 상기 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.Also, the first memory variable and the second memory variable may be global memory variables.

본 명세서에 따르면, GPU 범용 컴퓨팅 환경에서 애플리케이션 중단 없이 GPU 커널의 중단 및 재수행을 보장하는 효과가 있다.According to the present specification, there is an effect of ensuring that the GPU kernel is stopped and re-executed without stopping the application in the GPU general-purpose computing environment.

또한, 본 명세서에 따르면, 하드웨어 지원 없이 GPU 커널의 우선 순위에 따른 스케줄링을 지원할 수 있는 효과가 있다.In addition, according to the present specification, there is an effect that scheduling according to the priority of the GPU kernel can be supported without hardware support.

또한, 본 명세서에 따르면, 커널 실행을 중단하더라도 애플리케이션 실행이 유지되므로, 높은 우선순위의 GPU 커널이 발생하는 경우, 기존 커널의 실행을 중단하고, 우선순위가 높은 커널을 실행할 수 있는 효과가 있다.In addition, according to the present specification, since the application execution is maintained even if the kernel execution is stopped, when a high priority GPU kernel occurs, the execution of the existing kernel is stopped and the high priority kernel can be executed.

또한, 본 명세서에 따르면, GPU 커널이 임의 시점에 중단되더라도 데이터 일관성을 보장하며 재수행이 가능한 효과가 있다.In addition, according to the present specification, even if the GPU kernel is stopped at an arbitrary point in time, data consistency is guaranteed and re-execution is possible.

또한, 본 명세서에 따르면, 하드웨어 지원 없이 추가적인 컨텍스트 저장없이 멱등 GPU 커널을 수행하여 선점형 우선순위 스케쥴링을 지원 가능한 효과가 있다.In addition, according to the present specification, there is an effect that preemptive priority scheduling can be supported by performing an idempotent GPU kernel without additional context storage without hardware support.

본 발명에서 얻을 수 있는 효과는 이상에서 언급한 효과로 제한되지 않으며, 언급하지 않은 또 다른 효과들은 아래의 기재로부터 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 명확하게 이해될 수 있을 것이다.The effects obtainable in the present invention are not limited to the above-mentioned effects, and other effects not mentioned will be clearly understood by those of ordinary skill in the art to which the present invention pertains from the description below. .

본 발명에 관한 이해를 돕기 위해 상세한 설명의 일부로 포함되는, 첨부 도면은 본 발명에 대한 실시 예를 제공하고, 상세한 설명과 함께 본 발명의 기술적 특징을 설명한다.
도 1은 메모리 접근 패턴에 따른 멱등 보장 유무를 간단히 표현한 일 예를 나타낸다.
도 2는 접근 플래그 비트맵을 설명하기 위한 도면이다.
도 3은 본 발명의 일 실시 예에 따른 멱등 커널 생성 장치의 동작을 설명하기 위한 흐름도이다.
도 4는 멱등 커널 생성 장치의 동작을 설명하기 위한 소스 코드의 간단한 일 예이다.
도 5는 본 발명의 일 실시 예에 따른 멱등 커널 생성 방법을 나타내는 흐름도이다.
도 6은 본 발명의 다른 일 실시 예에 따른 멱등 커널 생성 방법을 나타내는 흐름도이다.
도 7은 본 명세서에서 제안하는 일 실시 예에 따른 멱등 커널 생성 장치를 나타내는 도면이다.
도 8은 본 명세서에서 제안하는 다른 일 실시 예에 따른 멱등 커널 생성 장치를 나타내는 도면이다.
도 9는 관리 구조를 설명하기 위한 도면이다.
BRIEF DESCRIPTION OF THE DRAWINGS The accompanying drawings, which are included as a part of the detailed description to help the understanding of the present invention, provide embodiments of the present invention, and together with the detailed description, explain the technical features of the present invention.
1 shows an example of simply expressing whether or not idempotency is guaranteed according to a memory access pattern.
2 is a diagram for explaining an access flag bitmap.
3 is a flowchart illustrating an operation of an apparatus for generating an idempotent kernel according to an embodiment of the present invention.
4 is a simple example of a source code for explaining an operation of an idempotent kernel generator.
5 is a flowchart illustrating a method for generating an idempotent kernel according to an embodiment of the present invention.
6 is a flowchart illustrating a method for generating an idempotent kernel according to another embodiment of the present invention.
7 is a diagram illustrating an apparatus for generating an idempotent kernel according to an embodiment proposed in the present specification.
8 is a diagram illustrating an apparatus for generating an idempotent kernel according to another embodiment proposed in the present specification.
9 is a diagram for explaining a management structure.

이하, 본 발명에 따른 바람직한 실시 형태를 첨부된 도면을 참조하여 상세하게 설명한다. 첨부된 도면과 함께 이하에 개시될 상세한 설명은 본 발명의 예시적인 실시형태를 설명하고자 하는 것이며, 본 발명이 실시될 수 있는 유일한 실시형태를 나타내고자 하는 것이 아니다. 이하의 상세한 설명은 본 발명의 완전한 이해를 제공하기 위해서 구체적 세부사항을 포함한다. 그러나, 당업자는 본 발명이 이러한 구체적 세부사항 없이도 실시될 수 있음을 안다. Hereinafter, preferred embodiments according to the present invention will be described in detail with reference to the accompanying drawings. DETAILED DESCRIPTION The detailed description set forth below in conjunction with the appended drawings is intended to describe exemplary embodiments of the present invention and is not intended to represent the only embodiments in which the present invention may be practiced. The following detailed description includes specific details in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that the present invention may be practiced without these specific details.

GPU 커널에서 메모리 수준의 멱등(Idempotence)을 만족 시키는 것의 의미는 커널에 전달된 글로벌 메모리 변수에 대해서 일관성을 보장함으로써 임의의 순간에 중단되었다가 재수행되더라도 동일한 결과를 기대할 수 있는 것을 의미할 수 있다.Satisfying memory level idempotence in the GPU kernel means that the same result can be expected even if it is interrupted and restarted at any moment by ensuring consistency for the global memory variable passed to the kernel. .

이하에서는, 본 발명의 멱등 커널 생성 방법 및 장치를 설명하기에 앞서 간단한 예시를 통해 WAR 위험(hazard)의 개념 및 멱등성(Idempotence)을 설명한다.Hereinafter, the concept of a WAR hazard and idempotence will be described through a simple example before describing the method and apparatus for generating an idempotent kernel of the present invention.

소스 코드 내에 변수에 대한 읽기 접근이 있은 후에 해당 변수에 대한 쓰기가 발생하는 메모리 접근 패턴이 존재한다면, 해당 소스 코드는 멱등성(Idempotence)이 보장되지 않을 수 있다. 만일, WAR 데이터 위험(hazard)을 가진 변수가 초기 접근 이전에 임의의 값으로 초기화 된다면, 소스 코드를 재수행하더라도 항상 같은 데이터를 가지고 수행되므로 해당 소스 코드의 멱등성(Idempotence)은 보장될 수 있다.If there is a memory access pattern in which a write to a variable occurs after a read access to the variable exists in the source code, the idempotence of the source code may not be guaranteed. If a variable with a WAR data hazard is initialized to a random value before initial access, even if the source code is re-executed, it is always performed with the same data, so the idempotence of the source code can be guaranteed. .

도 1은 메모리 접근 패턴에 따른 멱등 보장 유무를 간단히 표현한 일 예를 나타낸다.1 shows an example of simply expressing whether or not idempotency is guaranteed according to a memory access pattern.

도 1을 참조하면, 도 1(a)의 경우, 변수 A, B은 WAR 위험 접근 패턴을 가지고 있다. 정상적으로 수행되는 도 1(a)의 코드는 A와 B의 값이 서로 치환되는 결과를 가질 수 있다. 하지만, A에 B를 저장한 후(A=B;), 소스 코드가 중단된다면, 해당 소스 코드의 재수행 시, 초기 A값이 B로 변경된 상태이므로 기대한 결과를 얻을 수 없다. Referring to FIG. 1 , in the case of FIG. 1 ( a ), variables A and B have a WAR risk approach pattern. The normally executed code of FIG. 1( a ) may have a result in which the values of A and B are substituted with each other. However, if the source code is interrupted after storing B in A (A=B;), the expected result cannot be obtained because the initial value of A is changed to B when the source code is re-executed.

예를 들면, 초기값이 A=1, B=2인 경우를 가정할 수 있다. 정상적인 경우, tmp는 1의 값을 저장하고(tmp=A), A는 2의 값으로 변경된다(A=B). 다음, B는 1의 값으로 변경된다(B=tmp). 결과적으로, A=2, B=1로 서로 치환되는 결과 값을 가질 수 있다. 하지만, A의 값을 B의 값으로 변경한 후(A=B), 중단된 경우, A=2, B=1되며, 다시 소스 코드를 재수행 시, tmp는 2의 값을 저장하고(tmp=A), A는 2의 값을 유지한다(A=B). 다음, B는 2의 값을 유지한다(B=tmp). 이와 같이 잘못된 결과를 가질 수 있다.For example, it may be assumed that the initial values are A=1 and B=2. Normally, tmp stores a value of 1 (tmp=A), and A is changed to a value of 2 (A=B). Next, B is changed to a value of 1 (B=tmp). As a result, A=2 and B=1 may have result values substituted for each other. However, after changing the value of A to the value of B (A=B), if it is stopped, A=2, B=1, and when the source code is executed again, tmp stores the value of 2 (tmp =A), A maintains the value of 2 (A=B). Next, B maintains a value of 2 (B=tmp). This can lead to erroneous results.

도 1(b)의 경우, 소스 코드 수행 전에 A와 B의 값은 초기화(A=1; B=2;)되는 경우로, 이러한 경우 A와 B 값은 임의의 시점에 중단되더라도 기대한 결과를 얻을 수 있다. In the case of Fig. 1(b), the values of A and B are initialized (A=1; B=2;) before the source code is executed. In this case, the values of A and B show the expected results even if they are stopped at any time. can be obtained

예를 들면, 정상인 경우, 코드 시작에서, A=1, B=2로 초기화된다. 다음, 변수 tmp는 1의 값을 갖는다(tmp=A). 다음, A는 2의 값을 갖는다(A=B). 다음, B는 1의 값을 갖는다(B=tmp). 만약, A는 2의 값을 갖은 후(A=B), 중단되고, 재수행 시, 다시 A=1, B=2로 초기화부터 시작하므로, 도 1(a)와 같은 문제는 발생하지 않는다.For example, in the normal case, at the beginning of the code, A=1, B=2 is initialized. Next, the variable tmp has a value of 1 (tmp=A). Then, A has a value of 2 (A=B). Next, B has a value of 1 (B=tmp). If A has a value of 2 (A=B), it is stopped, and when re-executing, it starts from initialization again with A=1 and B=2, so the problem as shown in FIG. 1(a) does not occur.

본 명세서는 GPU 환경에서 GPU 커널의 저장 없이 바로 재수행이 가능한 멱등 GPU 커널 코드를 생성하기 위한 방법(멱등 커널 생성 방법)을 제안한다. 해당 방법은 즉각적인 선점 지원을 지원할 수 있다.The present specification proposes a method for generating an idempotent GPU kernel code that can be immediately re-executed without storing the GPU kernel in a GPU environment (a method for generating an idempotent kernel). The method can support immediate preemption support.

이하, 본 명세서는 멱등 커널 생성 방법을, 정적 분석을 통한 멱등 커널 생성 방법(이하, 제1 실시 예)와, 접근 플래그 비트맵을 통한 멱등 커널 생성 방법(이하, 제2 실시 예)로 구분하여 살펴본다.Hereinafter, the present specification divides the idempotent kernel generation method into a method for generating an idempotent kernel through static analysis (hereinafter, the first embodiment) and a method for generating an idempotent kernel through an access flag bitmap (hereinafter, the second embodiment). Let's take a look.

이하, 본 명세서에서 설명되는 실시 예들은 설명의 편의를 위해 구분된 것일 뿐, 어느 실시 예의 일부 방법 및/또는 일부 구성 등이 다른 실시 예의 방법 및/또는 구성 등과 치환되거나, 상호 간 결합되어 적용될 수 있음은 물론이다.Hereinafter, the embodiments described in the present specification are only divided for convenience of description, and some methods and/or components of one embodiment may be substituted or applied in combination with methods and/or components of other embodiments. of course there is

제1 실시 예first embodiment

먼저, 정적 분석을 통한 멱등 커널 생성 방법을 구체적으로 살펴본다.First, a detailed look at how to create an idempotent kernel through static analysis.

(멱등 GPU 커널 생성을 위한 정적 분석)(Static analysis to create idempotent GPU kernels)

멱등 커널 생성 장치는 멱등(idempotent) GPU 커널 생성을 위한 정적 분석을 수행할 수 있다.The idempotent kernel generator may perform static analysis for generating an idempotent GPU kernel.

멱등 커널 생성 장치는 GPGPU 프로그램 소스 코드 내에 GPU에서 수행되는 코드 영역에 대해서 WAR 데이터 위험 패턴(또는, WAR 위험) 발생을 추적하여 코드의 멱등 유무를 확인하고, WAR 패턴 발생하는 변수들의 정보를 확인할 수 있다.The idempotent kernel generation device traces the occurrence of a WAR data risk pattern (or WAR risk) in the code area executed on the GPU within the GPGPU program source code to check whether the code is idempotent, and to check the information of the variables that the WAR pattern occurs. have.

구체적으로, 멱등 커널 생성 장치는 GPU 함수 정보를 확인할 수 있다. GPU 함수 정보는 GPGPU 프로그램 소스 코드에서 GPU 하드웨어에서 수행되는 커널 함수 정보 및/또는 디바이스 함수 정보일 수 있다.Specifically, the idempotent kernel generating apparatus may check GPU function information. The GPU function information may be kernel function information and/or device function information performed in GPU hardware in the GPGPU program source code.

GPGPU 프로그래밍 모델을 지원하는 병렬 컴퓨팅 라이브러리(CUDA/OpenCL)에서는 GPU에서 수행되는 함수를 특정 지시자를 통해 커널/디바이스 함수로 구분하고 있다. 이러한 지시자를 통해 멱등 커널 생성 장치는 GPU 하드웨어에서 수행되는 함수를 구분하고 그에 대한 정보인 지시자, 함수 이름, 파라미터, 반환 형태 정보를 추출하여 정적 분석을 위한 구조를 생성할 수 있다.The parallel computing library (CUDA/OpenCL) that supports the GPGPU programming model classifies functions performed on the GPU into kernel/device functions through specific directives. Through these directives, the idempotent kernel generator can create a structure for static analysis by classifying functions performed in GPU hardware and extracting information about the indicators, function names, parameters, and return types.

OpenCL의 경우 GPU에서 수행되는 코드에 의해 호출되는 함수를 인라인 함수 형태로 정의하기 때문에, 이에 대해 추적 하기 위해서, 멱등 커널 생성 장치는 코드 내에 함수 호출 정보를 추적하여 디바이스 함수 정보를 구분해 낼 수 있다.In the case of OpenCL, a function called by the code executed on the GPU is defined in the form of an inline function. In order to track this, the idempotent kernel generator tracks the function call information in the code and distinguishes the device function information. .

멱등 커널 생성 장치는 GPU 코드 수행 중 함수 호출 관계로 인해 발생할 수 있는 WAR 위험을 추적하기 위해서, 먼저 각 함수 블록 내부의 WAR 위험 추적한 후에 함수 간 글로벌 메모리 변수 전달 관계를 추적하여 해당 변수의 전역적 WAR 위험을 확인할 수 있다.The idempotent kernel generator first tracks the WAR risk inside each function block and then traces the global memory variable transfer relationship between functions in order to track the WAR risk that can occur due to the function call relationship during GPU code execution. WAR risk can be identified.

다음, 멱등 커널 생성 장치는 GPU 함수에 전달되는 글로벌 메모리 변수 정보를 확인할 수 있다.Next, the idempotent kernel generator may check the global memory variable information passed to the GPU function.

GPU 함수의 매개변수는 일반적인 C 및/또는 C++과 마찬가지로 값에 의한 호출(Call by Value) 및/또는 참조에 의한 호출(Call by Reference) 형태를 가질 수 있다. 글로벌 메모리 변수는 참조에 의한 호출(Call by Reference) 형태로 전달될 수 있다. 글로벌 메모리 변수는 GPU 함수로 포인터(Pointer) 형태 또는 참조(Reference) 형태로 전달되며, 멱등 커널 생성 장치는 C 및/또는 C++ 명세에 따라 ' * ' 및/또는 ' & ' 지시자를 통해 글로벌 메모리 변수를 확인할 수 있다.The parameters of the GPU function may have the form of a call by value and/or a call by reference as in general C and/or C++. A global memory variable may be passed in the form of a call by reference. Global memory variables are passed to GPU functions in the form of pointers or references, and the idempotent kernel generator uses ' * ' and/or ' & ' directives according to the C and/or C++ specification to determine global memory variables. can be checked.

(WAR 패턴 정보 생성)(Generate WAR pattern information)

다음, 멱등 커널 생성 장치는 글로벌 메모리 변수 접근 패턴 정보(WAR 패턴 정보)를 생성 및/또는 확인할 수 있다. Next, the idempotent kernel generating device may generate and/or check global memory variable access pattern information (WAR pattern information).

멱등 커널 생성 장치는 소스 코드 내에 연산자 패턴을 통해 변수 읽기 및/또는 쓰기 접근을 구분하여 확인할 수 있다.The idempotent kernel generator can be checked by distinguishing variable read and/or write access through operator patterns in the source code.

예를 들면, (1) ' = ' 대입 연산자는 가장 끝에 있는 좌 항 변수에 대한 쓰기 접근, 그 외에 모든 변수에 대한 읽기 접근으로 확인될 수 있다.For example, (1) ' = ' assignment operator can be confirmed as write access to the last variable on the left, and read access to all other variables.

(2) ' += ' 복합 연산자는 가장 끝에 있는 좌 항 변수에 대한 읽기 접근 후 쓰기 접근으로 확인될 수 있다.(2) The ' += ' compound operator can be checked as a read access and then a write access to the leftmost variable.

(3) '++' 단항 연산자는, 대상 변수에 대한 읽기 후 쓰기 접근으로 확인될 수 있다.(3) The '++' unary operator can be identified as a read-and-write access to the target variable.

(4) 함수 호출 시에 매개변수로 전달되는 경우, 각 함수 내의 분석 이후 전역적 분석을 통해 접근 패턴은 확인될 수 있다.(4) When passed as a parameter when calling a function, access patterns can be identified through global analysis after analysis within each function.

(5) 상술한 세 가지 연산자를 제외한 모든 연산자는 변수에 대한 읽기 접근으로 확인될 수 있다.(5) All operators except for the above three operators can be identified as read access to variables.

그리고/또는, 멱등 커널 생성 장치는 변수 접근 관리 구조 형성을 통해 WAR 패턴 정보를 확인할 수 있다.And/or, the idempotent kernel generator may check WAR pattern information by forming a variable access management structure.

각 글로벌 메모리 변수에 대한 관리 구조를 형성하고, 코드 내에 순차적인 변수 접근 패턴을 기록하여 WAR 패턴 발생 유무를 확인할 수 있다. By forming a management structure for each global memory variable and recording sequential variable access patterns in the code, it is possible to check whether a WAR pattern occurs.

글로벌 메모리 변수는 참조에 의한 호출(Call-by-Reference)로 전달되기 때문에 포인터가 가리키는 영역이 구조화(Struct) 되어 있어 ' . ' 또는 '->' 형태의 포인터 접근이 이루어질 수 있다. 이러한 경우를 고려하여 최종적으로 접근되는 변수를 확인할 수 있다.Since global memory variables are passed by call-by-reference, the area pointed to by the pointer is structured so that ' . ' or '->' type of pointer access can be made. Considering this case, it is possible to check the finally accessed variable.

그리고/또는, 배열 형태의 변수가 사용되는 경우(일반적) 실제 접근 되는 메모리 영역의 위치는 인덱스를 통해 결정될 수 있다. 멱등 커널 생성 장치는 해당 인덱스를 고려하여 WAR 패턴 발생 유무를 판단하고, WAR 패턴 정보를 생성 및/또는 확인할 수 있다.And/or, when an array-type variable is used (generally), the location of the memory area that is actually accessed may be determined through an index. The apparatus for generating an idempotent kernel may determine whether a WAR pattern has occurred in consideration of the corresponding index, and may generate and/or check WAR pattern information.

그리고/또는, 멱등 커널 생성 장치는 앨리어스 포인터(Alias Pointer) 정보를 확인할 수 있다. GPU 커널 함수에 전달된 글로벌 메모리 변수(포인터)를 함수의 지역 포인터 변수에 저장하여 사용하는 경우, 해당 지역 포인터 변수에 대한 접근은 실제 글로벌 메모리 변수에 대한 접근이기 때문에 확인할 필요가 있을 수 있다. 멱등 커널 생성 장치는 함수 내에 지역 포인터 변수가 선언되는 경우를 인지하고 해당 변수를 초기화하는데 사용된 변수들을 추적해서 최종적으로 연관되는 글로벌 메모리 변수 및/또는 WAR 패턴 정보를 확인 및/또는 생성할 수 있다.And/or, the apparatus for generating an idempotent kernel may check alias pointer information. When using the global memory variable (pointer) passed to the GPU kernel function by storing it in the function's local pointer variable, it may be necessary to check the access to the local pointer variable because it is an access to the actual global memory variable. The idempotent kernel generator can recognize when a local pointer variable is declared within a function, track the variables used to initialize the variable, and finally check and/or create the associated global memory variable and/or WAR pattern information. .

(멱등 GPU 커널 생성)(creating an idempotent GPU kernel)

다음, 멱등 커널 생성 장치는 멱등(Idempotent) GPU 커널을 생성할 수 있다. 제1 실시 예에서는 정적 멱등 커널을 생성할 수 있다.Next, the idempotent kernel generating apparatus may generate an idempotent GPU kernel. In the first embodiment, a static idempotent kernel may be generated.

멱등 커널 생성 장치는 GPU 커널의 멱등성이 보장을 위한 리다이렉션(Redirection)을 수행할 수 있다. 멱등 커널 생성 장치는 WAR 패턴 정보에 기초하여 WAR 위험이 발생하는 변수에 대한 접근을 다른 영역으로 리다이렉션(Redirection)할 수 있다. 초기 변수 접근으로 읽기 접근 후 쓰기 접근 발생시, 면등 커널 생성 장치는 쓰기 접근 발생 전에 추가적으로 할당된 다른 글로벌 메모리 영역에 쓰기 동작을 수행하도록 유도(Redirection)할 수 있다. 멱등 커널 생성 장치는 쓰기에 대한 리다이렉션된 변수에 대해서는 그 이후 읽기 및/또는 쓰기 모두 리다이렉션된 영역에서 이루어지도록 변수 명칭을 치환할 수 있다. 멱등 커널 생성 장치는 GPU 커널이 모두 수행된 이 후 커널 종료 직전에 리다이렉션된 영역을 원본에 반영함으로써, 데이터의 일관성을 유지시킬수 있다.The idempotent kernel generator may perform redirection to ensure idempotency of the GPU kernel. The idempotent kernel generator may redirect access to a variable in which a WAR risk occurs to another area based on WAR pattern information. When a write access occurs after a read access as an initial variable access, the kernel-generated device may induce (redirection) to perform a write operation in another global memory area that is additionally allocated before the write access occurs. The idempotent kernel generator may substitute a variable name for a redirected variable for write so that both reads and/or writes thereafter are performed in the redirected area. The idempotent kernel generator can maintain data consistency by reflecting the redirected area to the original just before the kernel is terminated after the GPU kernel is all executed.

제2 실시 예second embodiment

다음, 접근 플래그 비트맵을 통한 멱등 커널 생성 방법을 구체적으로 살펴본다.Next, the method of generating an idempotent kernel through the access flag bitmap will be described in detail.

멱등 커널 생성 장치는 동적 결정 요소를 고려하여 멱등 GPU 커널 생성할 수 있다. 멱등 커널 생성 장치는 정적으로 결정되지 않는 코드 내의 비결정 멱등을 확인할 수 있다. 소스 코드 내에서 조건문 및/또는 동적으로 결정되는 인덱스에 따라 정적으로 해당 변수의 접근 및/또는 위치를 확정하지 못하는 경우, 명칭 변환을 통해 코드의 멱등성(idempotence)은 보장될 수 없다. The idempotent kernel generator may generate an idempotent GPU kernel in consideration of a dynamic determinant. An idempotent kernel generator can check for non-deterministic idempotency in code that is not statically determined. If the access and/or position of the variable cannot be statically determined according to a conditional statement and/or a dynamically determined index in the source code, idempotence of the code cannot be guaranteed through name conversion.

동적으로 결정되는 요소를 기반으로 멱등 GPU 커널을 생성 하기 위해서, 멱등 커널 생성 장치는 도 2와 같이, 해당 변수의 메모리 내에 절대적 위치에 대한 읽기 접근 및/또는 쓰기 접근을 추적할 수 있는 접근 플래그 비트맵을 설정하는 코드를 삽입할 수 있다. 멱등 커널 생성 장치는 도 2와 같이, 글로벌 메모리 변수의 인덱스를 기반으로 결정된 영역에 대해 1비트(bit) 접근 플래그 비트를 맵핑하여 접근 발생시 1로 치환할 수 있다.In order to generate an idempotent GPU kernel based on a dynamically determined element, the idempotent kernel generating device is an access flag bit capable of tracking read access and/or write access to an absolute location in the memory of the corresponding variable, as shown in FIG. 2 . You can insert code to set the map. As shown in FIG. 2 , the apparatus for generating an idempotent kernel may map a 1-bit access flag bit to an area determined based on an index of a global memory variable, and substitute 1 when an access occurs.

도 2는 일 실시 예에 따른 멱등 커널 생성 장치의 전체적인 개요를 설명하기 위한 도면이다. 도 2를 참조하면, 하위 항목인 GPU Kernel Transfiler를 통해 정적으로 멱등 커널을 생성하며, 동적으로 결정되는 요소로 인해(예로 들어, 인덱스가 동적으로 결정되는 경우 어디에 접근되는지 알수 없어서 WAR 추적 불가능) 정적으로 분석 및/또는 변환 불가능한 부분에 대해서 글로벌 메모리 접근 플래그 비트맵(Global Memory Access Flag Bitmap)을 통해 추적할 수 있다. 2 is a diagram for explaining an overall outline of an apparatus for generating an idempotent kernel according to an embodiment. Referring to Figure 2, an idempotent kernel is statically created through the GPU Kernel Transfiler, which is a sub-item, and due to a dynamically determined element (for example, when an index is dynamically determined, it is not possible to track the WAR because it is not known where it is accessed) Static It can be traced through the Global Memory Access Flag Bitmap for parts that cannot be analyzed and/or converted to

그리고/또는, 이와 같은 정적 및/또는 동적 방법을 통해 WAR 메모리 접근 패턴이 발견되면 원본 영역을 유지하기 위해서 글로벌 메모리 영역(Global Memory Region)에서 원 공간(Original Space)이 아닌 리다이렉션 공간(Redirection Space)에 쓰고, 그 후에 이곳에서 읽기가 수행될 수 있다. WAR이 아닌 패턴의 경우 초기 상태 그대로 원 공간(Original Space)에 접근이 이루어질 수 있다.And/or, if a WAR memory access pattern is found through such a static and/or dynamic method, a redirection space, not the original space, in the global memory region to maintain the original region writes to, and then reads can be performed from there. In the case of a non-WAR pattern, access to the original space can be made as it is in the initial state.

도 3은 본 발명의 일 실시 예에 따른 멱등 커널 생성 장치의 동작을 설명하기 위한 흐름도이다.3 is a flowchart illustrating an operation of an apparatus for generating an idempotent kernel according to an embodiment of the present invention.

도 2 및 도 3을 참조하면, 먼저, 멱등 커널 생성 장치는 정적으로 결정되지 않는 GPU 커널함수 내에서 글로벌 메모리 변수의 WAR 위험(Hazard) (패턴)을 확인 (S320)하기 위해, GPU 커널함수 소스 코드를 정적 분석할 수 있다(S310).Referring to Figures 2 and 3, first, the idempotent kernel generating device is a GPU kernel function source in order to check (S320) the WAR risk (pattern) of the global memory variable within the GPU kernel function that is not statically determined. The code may be statically analyzed (S310).

다음, 멱등 커널 생성 장치는 GPU 커널함수 소스코드를 정적 분석을 통해 GPU 커널함수 내에서 글로벌 메모리 변수의 WAR 위험(Hazard) 유무를 판단할 수 있다. WAR 위험이 없는 경우, 멱등 커널 생성 장치는 GPU 디바이스 드라이버에 스케줄링 힌트 전달 코드를 삽입할 수 있다(S350).Next, the idempotent kernel generating device may determine whether there is a WAR hazard in the global memory variable in the GPU kernel function through static analysis of the GPU kernel function source code. If there is no WAR risk, the idempotent kernel generating apparatus may insert the scheduling hint transfer code into the GPU device driver (S350).

다음, 멱등 커널 생성 장치는 WAR 위험이 확인된 경우, 해당 변수에 대한 읽기(Read) 접근 및/또는 쓰기(Write) 접근을 추적하기 위한 접근 플래그 비트맵 설정 코드(또는, 동적 플래그 설정 코드)를 삽입할 수 있다(S330). 해당 코드를 통해, 접근 플래그 비트맵은 도 2와 같이, 읽기 접근 또는 쓰기 접근에 따라 값이 바뀔 수 있다.Next, the idempotent kernel generator generates an access flag bitmap setting code (or dynamic flag setting code) to track read access and/or write access to the variable when a WAR risk is identified. can be inserted (S330). Through the corresponding code, the value of the access flag bitmap may change according to read access or write access, as shown in FIG. 2 .

다음, 멱등 커널 생성 장치는 읽기 접근 또는 쓰기 접근에 따른 해당 변수에 대한 리다이렉션 코드를 삽입할 수 있다(S340). 해당 코드를 통해, 처리 장치는 접근 플래그 비트맵에 기초하여 동적으로 WAR 위험을 확인하고, 글로벌 메모리의 원본 영역을 사용할 지 또는 글로벌 메모리의 리다이렉션 영역을 사용할지 결정하여 연산을 수행할 수 있다.Next, the device for generating an idempotent kernel may insert a redirection code for a corresponding variable according to a read access or a write access (S340). Through this code, the processing unit can dynamically check for a WAR risk based on the access flag bitmap and perform the operation by determining whether to use the original area of global memory or the redirect area of global memory.

도 4는 멱등 커널 생성 장치의 동작을 설명하기 위한 소스 코드의 간단한 일 예이다. 도 4(a)는 변경 없는 커널 함수 코드이고, 도 4(b)는 멱등 커널 생성 장치에 의해 생성 및/또는 변환된 커널 함수 코드를 보여준다.4 is a simple example of a source code for explaining an operation of an idempotent kernel generator. Fig. 4(a) is an unaltered kernel function code, and Fig. 4(b) shows a kernel function code generated and/or converted by the idempotent kernel generating device.

도 4(b)를 참조하면, 도 4(b)의 rbit[(tid+i)/8]=!(wbit[(tid+i)/8]&(tid+i)%8)I(rbit[(tid+i)/8]&(tid+i)%8); 과, wbit[(tid+i)/8]=1<<(tid+i)%8;은 접근 플래그 비트맵을 세팅하는 소스 코드 및/또는 연산으로, 이는 글로벌 메모리 변수의 자료형 크기와 1비트의 플래그를 맵핑 시키는 연산을 포함하며 또한 읽기 접근에 대해서 이전 쓰기 접근 플래그를 참조하여 RAW 패턴 유무를 추적함으로써, 코드 순서가 아닌 실제 접근에 따른 WAR 위험을 확인할 수 있다.4(b), rbit[(tid+i)/8]=!(wbit[(tid+i)/8]&(tid+i)%8)I(rbit) in FIG. 4(b) [(tid+i)/8]&(tid+i)%8); and wbit[(tid+i)/8]=1<<(tid+i)%8; is the source code and/or operation to set the access flag bitmap, which is the data type size of the global memory variable and 1 bit It includes an operation that maps the flags of , and by tracking the existence of RAW patterns by referring to the previous write access flag for read access, you can check the WAR risk according to the actual access, not the code order.

예를 들면, GPU 커널 함수에서 사용되는 임의의 글로벌 메모리 변수는 임의의 타입 배열 형태로 구성될 수 있다. 이러한 글로벌 메모리 변수(배열)에 대해서 인덱스로 접근 가능한 단위(배열 요소)를 접근 플래그 메모리 영역의 1 비트에 대응 시킬 수 있다. 예로 들면, int G[10] 이라는 글로벌 메모리 변수 G가 전달될 때 rbit[] 및/또는 wbit[] 메모리 영역의 1 비트는 G의 한 개의 인덱스로 가리키는 영역(word)와 대응될 수 있다. For example, any global memory variable used in the GPU kernel function may be configured in the form of an arbitrary type array. For such a global memory variable (array), a unit (array element) accessible by an index can be mapped to 1 bit of the access flag memory area. For example, when a global memory variable G called int G[10] is transmitted, one bit of the rbit[] and/or wbit[] memory area may correspond to a word indicated by one index of G.

또한, rbit의 역할은 두 가지로, 만약 커널이 동작 중에 글로벌 메모리 영역에 접근될 때 읽기(Read)가 발생했다는 사실을 기록하는 것과, 만약 RAW(Read after Write) 패턴이 발생했는지 wbit를 통해 그 유무를 기록하는 것일 수 있다. RAW 발생 유무를 체크해서 rbit를 세팅하는 이유는 RAW가 발생하는 것은 원본 데이터 영역이 항상 실행 때마다 초기화가 된 후에 읽기가 발생하므로 멱등성(수행 중 임의의 순간에 중단되었다가 재 수행되어도 동일한 결과를 기대할 수 있는 것)을 해치지 않기 때문이다.In addition, the role of rbit is twofold. If the kernel accesses the global memory area during operation, it records the fact that a read has occurred, and if a RAW (Read after Write) pattern occurs, it is determined through wbit. It may be to record the presence or absence. The reason for setting the rbit by checking whether RAW occurs is idempotency (even if it is interrupted and re-executed at any moment during execution, the result is the same as the read occurs after the original data area is always initialized when RAW occurs). Because it does not harm what can be expected).

멱등 커널 생성 장치는 동적으로 결정되는 변수 접근 패턴에 따라 리다이렉션(Redirection) 유무 결정할 수 있다.The idempotent kernel generator may determine whether or not redirection exists according to a dynamically determined variable access pattern.

리다이렉션을 동적으로 결정하기 위해서 함수 내부에 도 4(b)와 같이 지역 변수로 임시 포인터 변수를(A_addr) 선언하고 전달된 글로벌 메모리 변수로 초기화 함으로써 초기 접근은 원본 영역에서 이루어지도록 할 수 있다.In order to dynamically determine the redirection, the initial access can be made in the original area by declaring a temporary pointer variable (A_addr) as a local variable inside the function as shown in Fig. 4(b) and initializing it with the global memory variable passed.

읽기 및/또는 쓰기에 대한 접근 플래그가 세팅된 이후 쓰기 발생 전에 임시 포인터 변수를 WAR 발생 유무에 따라 원본 영역으로 할지 리다이렉션 영역으로 할지 결정하고, 그 이후에 접근은 치환된 영역에서 이루어지도록 할 수 있다.After the access flag for read and/or write is set, before write occurs, it is decided whether to use the temporary pointer variable as the original area or the redirection area according to the occurrence of WAR, and then access can be made in the replaced area. .

도 5는 본 발명의 일 실시 예에 따른 멱등 커널 생성 방법을 나타내는 흐름도이다.5 is a flowchart illustrating a method for generating an idempotent kernel according to an embodiment of the present invention.

도 5에 도시된 멱등 커널 생성 방법은 멱등(Idempotent) 커널 생성 장치에 의해 수행될 수 있다. 예를 들면, 멱등 커널 생성 장치는 그래픽 처리 장치(Graphic Processing Unit, GPU), 중앙 처리 장치(Central Processing Unit, CPU), 또는 이외의 연산 장치일 수 있다.The method for generating an idempotent kernel shown in FIG. 5 may be performed by an idempotent kernel generating apparatus. For example, the idempotent kernel generating unit may be a graphic processing unit (GPU), a central processing unit (CPU), or other computing units.

도 5를 참조하면, 먼저, 멱등 커널 생성 방법은, GPU 커널함수와 관련된 소스 코드로부터 WAR(Write After Read) 패턴 정보를 생성하는 단계(S510)와, WAR 패턴 정보에 기초하여 제1 메모리 변수에 대한 WAR 위험이 발생하는 읽기 접근 후 쓰기 접근이 확인된 경우, 쓰기 접근에 대한 코드 전에, 제1 메모리 변수를 제2 메모리 영역 변수로 치환하는 코드를 삽입하는 단계(S520)를 포함할 수 있다.Referring to FIG. 5 , first, the method for generating an idempotent kernel includes generating WAR (Write After Read) pattern information from a source code related to a GPU kernel function ( S510 ), and based on the WAR pattern information, it is stored in a first memory variable. When the write access is confirmed after the read access that causes the WAR risk for the write access, before the code for the write access, the step of inserting a code for replacing the first memory variable with the second memory area variable (S520) may be included.

WAR 패턴 정보는 WAR 위험(harzad)이 발생하거나 발생할 수 있는 하나 이상의 글로벌 메모리 변수들을 포함할 수 있다. 또는, WAR 패턴 정보는 WAR 위험이 발생하는 연산자 및/또는 소스 코드를 포함할 수 있다.The WAR pattern information may include one or more global memory variables in which a WAR hazard occurs or may occur. Alternatively, the WAR pattern information may include an operator and/or source code in which a WAR risk occurs.

제1 메모리 변수 및 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.The first memory variable and the second memory variable may be global memory variables.

WAR 패턴 정보를 생성하는 단계(S510)는, 상기 소스 코드에서 GPU 커널함수를 확인하는 단계(S511)와, 상기 GPU 커널함수에 전달되는 글로벌 메모리 변수를 확인하는 단계(S512)와, 상기 GPU 커널함수 및 상기 글로벌 메모리 변수에 기초하여 상기 WAR 패턴 정보를 생성하는 단계(S513)를 포함할 수 있다.The step of generating the WAR pattern information (S510) includes the steps of checking the GPU kernel function from the source code (S511), checking the global memory variable transferred to the GPU kernel function (S512), and the GPU kernel It may include generating the WAR pattern information based on a function and the global memory variable (S513).

먼저, 멱등 커널 생성 장치는 소스 코드에서 GPU 커널함수를 확인할 수 있다(S511). First, the idempotent kernel generating device may check the GPU kernel function from the source code (S511).

예를 들면, 소스 코드는 GPU 상 범용 계산(General-Purpose on Graphics Processing Units, GPGPU) 프로그램 소스 코드일 수 있다.For example, the source code may be a General-Purpose on Graphics Processing Units (GPGPU) program source code.

멱등 커널 생성 장치는 특정 지시자에 의해 상기 GPU 커널함수와 디바이스 함수를 확인(또는 구분)할 수 있다. 예를 들면, OpenCL 라이브러리의 경우, __kernel 지시자(특정 지시자)를 통해 커널 함수임을 나타내고, CUDA 라이브러리의 경우, __global__ 지시자(특정 지시자)를 통해 커널 함수를 나타낼 수 있다.The apparatus for generating an idempotent kernel may identify (or distinguish) the GPU kernel function and the device function according to a specific indicator. For example, in the case of the OpenCL library, a kernel function can be indicated through the __kernel directive (specific directive), and in the case of the CUDA library, the kernel function can be indicated through the __global__ directive (specific directive).

예를 들면, GPGPU 프로그래밍 모델을 지원하는 병렬 컴퓨팅 라이브러리(CUDA/OpenCL)에서는 GPU에서 수행되는 함수를 특정 지시자를 통해 커널 함수와, 디바이스 함수로 구분하고 있다. 따라서, 멱등 커널 생성 장치는 이러한 지시자를 통해 GPU 하드웨어에서 수행되는 함수를 커널 함수와, 디바이스 함수로 구분(또는, 확인)할 수 있다.For example, in the parallel computing library (CUDA/OpenCL) that supports the GPGPU programming model, functions performed on the GPU are divided into kernel functions and device functions through specific directives. Accordingly, the idempotent kernel generating apparatus may classify (or check) a function performed in GPU hardware into a kernel function and a device function through such an indicator.

그리고/또는, 멱등 커널 생성 장치는 정적 분석을 위한 함수에 대한 정보를 생성할 수 있다. 함수에 대한 정보는 지시자 정보, 함수 정보, 파라미터 정보, 및/또는 반환 정보를 포함할 수 있다. 예를 들면, 지시자 정보는 해당 함수가 커널 함수인지 다바이스 함수인지 나타내는 지시자에 대한 정보일 수 있다. 함수 정보는 함수 이름을 나타내는 정보일 수 있다. 파라미터 정보는, 함수에서 사용되는 파라미터를 나타내는 정보일 수 있다. 반환 정보는 함수의 반환 형태를 나타내는 정보일 수 있다. 그리고/또는, 멱등 커널 생성 장치는 상기 함수에 대한 정보를 통해 구조를 생성할 수 있다.And/or, the idempotent kernel generating device may generate information about a function for static analysis. The information about the function may include indicator information, function information, parameter information, and/or return information. For example, the indicator information may be information on an indicator indicating whether the corresponding function is a kernel function or a device function. The function information may be information indicating a function name. The parameter information may be information indicating a parameter used in a function. The return information may be information indicating a return type of a function. And/or, the idempotent kernel generating apparatus may generate a structure through information on the function.

여기서, 생성되는 구조는 각 커널 함수의 정보를 관리하는 클래스를 의미할 수 있다. 해당 클래스에서는 함수의 이름, 파라미터, 반환값, 코드상에서 작성된 라인수를 기본 정보로 포함할 수 있다. 또한 후술하는 커널 함수에 전달된 글로벌 메모리 변수와 Alias pointer에 대한 접근 패턴을 관리하기 위한 구조를 포함할 수 있다. 예를 들면, 도 9에서 함수에 대한 정보를 관리하기 위한 구조는 Class FI 의 변수 Func Info 일 수 있다.Here, the generated structure may mean a class that manages information of each kernel function. In this class, the name of the function, parameters, return values, and the number of lines written in the code can be included as basic information. In addition, it may include a structure for managing access patterns for global memory variables and alias pointers passed to kernel functions to be described later. For example, in FIG. 9 , a structure for managing information about a function may be a variable Func Info of Class FI.

그리고/또는, 멱등 커널 생성 장치는 소스 코드 내에 함수 호출 정보를 추적하여 디바이스 함수를 확인(또는, 구분)할 수 있다.And/or, the apparatus for generating an idempotent kernel may identify (or identify) a device function by tracing function call information in the source code.

그리고/또는, 멱등 커널 생성 장치는 GPU 코드 수행 중 함수 호출 관계로 발생할 수 있는 WAR 위험을 추적하기 위해, 각 함수 블록 내부의 WAR 위험을 추적한 후, 함수 간 글로벌 메모리 변수 전달 관계를 추적하여, 해당 변수의 전역적 WAR 위험을 확인할 수 있다.And/or, the idempotent kernel generator tracks the WAR risk inside each function block in order to track the WAR risk that may occur due to the function call relationship during execution of the GPU code, and then traces the global memory variable transfer relationship between functions, You can check the global WAR risk of that variable.

다음, 멱등 커널 생성 장치는 상기 GPU 커널함수에 전달되는 글로벌 메모리 변수 및/또는 글로벌 메모리 변수에 대한 정보를 확인할 수 있다(S512).Next, the apparatus for generating an idempotent kernel may check information about the global memory variable and/or the global memory variable transmitted to the GPU kernel function (S512).

GPU 함수의 매개변수는 값에 의한 호출(Call by Value)과, 참조에 의한 호출(Call by Reference) 형태를 가질 수 있다. The parameters of the GPU function may have the form of a call by value and a call by reference.

또한, 글로벌 메모리 변수는 참조에 의한 호출(Call by Reference) 형태로 전달될 수 있다. 예를 들면, 글로벌 메모리 변수는 GPU 함수로 포인터(Pointer) 또는 참조(Reference) 형태로 전달될 수 있다. 따라서, 멱등 커널 생성 장치는 '*'및/또는 '&'지시자를 통해 글로벌 메모리 변수를 확인될 수 있다.In addition, the global memory variable may be transferred in the form of a call by reference. For example, a global memory variable may be passed to a GPU function in the form of a pointer or a reference. Accordingly, the idempotent kernel generator may identify global memory variables through '*' and/or '&' directives.

다음, GPU 커널함수 및 글로벌 메모리 변수에 기초하여 WAR 패턴 정보를 생성하는 단계(S513)는, GPU 커널함수 및 글로벌 메모리 변수와 관련된 연산자를 통해 읽기 접근 및 쓰기 접근을 확인하는 단계(S513-1)와, 글로벌 메모리 변수에 대한 읽기 접근과 쓰기 접근에 의해 WAR 패턴 정보를 생성하는 단계(S513-2)를 포함할 수 있다. 여기서, 글로벌 메모리 변수와 관련된 연산자는 글로벌 메모리 변수를 사용하는 연산자를 의미할 수 있다.Next, the step of generating WAR pattern information based on the GPU kernel function and the global memory variable (S513) is a step of checking the read access and the write access through the operator related to the GPU kernel function and the global memory variable (S513-1) and generating WAR pattern information by read access and write access to the global memory variable (S513-2). Here, the operator related to the global memory variable may mean an operator using the global memory variable.

예를 들면, 멱등 커널 생성 장치는 글로벌 메모리 변수와 관련된 연산자를 통해 다음과 같이 읽기 접근과 쓰기 접근을 확인할 수 있다.For example, an idempotent kernel generator can check read access and write access through operators related to global memory variables as follows.

(1) 대입 연산자(=)는 가장 끝의 좌항 변수에 대한 쓰기 접근으로, 그외 모든 변수에 대한 읽기 접근으로 확인될 수 있다.(1) The assignment operator (=) is a write access to the leftmost variable and can be confirmed as a read access to all other variables.

(2) 단항 연산자(++)는 대상 변수에 대한 읽기 접근 후 쓰기 접근으로 확인될 수 있다.(2) The unary operator (++) can be checked as a write access after a read access to the target variable.

(3) 복합 연산자(+=)는 가장 끝의 좌항 변수에 대한 읽기 접근 후 쓰기 접근으로 확인될 수 있다.(3) The compound operator (+=) can be confirmed as a write access after a read access to the leftmost variable.

(4) 함수의 호출은 각 함수에 대한 분석 후, 전역적 분석을 통해 읽기 접근 및/또는 쓰기 접근으로 확인될 수 있다.(4) The call of a function can be confirmed as read access and/or write access through global analysis after analysis of each function.

(5) 이외 연산자는 읽기 접근으로 확인될 수 있다.(5) Other operators can be checked with read access.

멱등 커널 생성 장치는 이와 같이 연산자를 통해 읽기 접근과 쓰기 접근을 확인하고, 읽기 접근 후 쓰기 접근이 발생하는 변수들 및/또는 코드들을 포함하는 WAR 패턴 정보를 생성할 수 있다. The idempotent kernel generator may check read access and write access through the operator as described above, and may generate WAR pattern information including variables and/or codes in which write access occurs after read access.

그리고/또는, 멱등 커널 생성 장치는 변수 접근 관리 구조 형성을 통해 WAR 패턴 정보를 생성할 수 있다. 예를 들면, 멱등 커널 생성 장치는 각 글로벌 메모리 변수에 대한 관리 구조를 형성하고, 소스 코드 내에 순차적인 변수 접근 패턴을 기록 및/또는 저장하여 WAR 위험을 확인할 수 있다. 글로벌 메모리 변수는 참조에 의한 호출(Call by Reference)로 전달되기 때문에 포인터가 가리키는 영역이 구조화되어 있어, '.' 또는 '->' 형태의 포인터 접근으로 이루어질 수 있다. 멱등 커널 생성 장치는 이러한 접근을 고려하여 최종적으로 접근되는 변수를 확인할 수 있다. 여기서, 글로벌 메모리 변수에 대한 관리 구조는 도 9에 도시된 Class VI 를 상속하여 생성되는 Class Param, Class Value, Class CallF 일 수 있다. 이것들은 기본적으로 해당 변수 명칭, 데이터 타입, 코드상의 위치(Line, Token)와 접근 정보를 관리하기 위한 Class UI(use info) 를 포함할 수 있다. Class UI의 경우, 해당 변수가 코드상에서 어디서(line, token) 어떻게(use type) 사용되는지에 대한 정보를 포함할 수 있다.And/or, the idempotent kernel generating device may generate WAR pattern information by forming a variable access management structure. For example, the idempotent kernel generation device may form a management structure for each global memory variable, and record and/or store sequential variable access patterns in the source code to check the WAR risk. Since global memory variables are passed by call by reference, the area pointed to by the pointer is structured, so '.' Alternatively, it can be made of pointer access in the form of '->'. The idempotent kernel generator can check the finally accessed variable in consideration of this approach. Here, the management structure for the global memory variable may be Class Param, Class Value, and Class CallF, which are created by inheriting the Class VI shown in FIG. 9 . These may include Class UI (use info) for managing the variable name, data type, location in code (Line, Token) and access information. In the case of Class UI, information on how (line, token) and how (use type) the variable is used in the code can be included.

그리고/또는, 배열 형태의 변수는 인덱스를 통해 메모리 영역의 위치가 결정되기 때문에 해당 인덱스를 고려하여 WAR 위험을 확인하고, WAR 패턴 정보를 생성할 수 있다.And/or, since the location of the memory area is determined through the index of the array-type variable, the WAR risk may be checked and WAR pattern information may be generated in consideration of the corresponding index.

그리고/또는, GPU 커널 함수에 전달되는 글로벌 메모리 변수를 함수의 지역 포인터 변수에 저장하여 사용하는 경우, 해당 지역 포인터 변수에 대한 접근은 글로벌 메모리 변수에 대한 접근으로 볼 수 있기 때문에 이를 추적할 필요가 있을 수 있다. 따라서, 멱등 커널 생성 장치는 함수 내 선언되는 지역 포인터 변수를 확인하고, 해당 변수를 초기화하는 데 사용되는 변수들을 추적하여 연관되는 글로벌 메모리 변수의 WAR 위험을 확인하고, WAR 패턴 정보를 생성할 수 있다.And/or, if a global memory variable passed to a GPU kernel function is stored and used in the function's local pointer variable, access to the local pointer variable can be viewed as access to the global memory variable, so it is not necessary to track it. there may be Therefore, the idempotent kernel generator can check the local pointer variable declared in the function, track the variables used to initialize the variable, check the WAR risk of the related global memory variable, and generate WAR pattern information. .

다음, 멱등 커널 생성 장치는 WAR 패턴 정보에 기초하여 제1 메모리 변수에 대한 WAR 위험이 발생하는 읽기 접근 후 쓰기 접근이 확인된 경우, 쓰기 접근에 대한 코드 전에, 제1 메모리 변수를 제2 메모리 영역 변수로 치환하는 코드를 삽입하는 단계(S520)를 포함할 수 있다.Next, the idempotent kernel generating device sets the first memory variable to the second memory area before the code for the write access when the write access is confirmed after the read access that causes the WAR risk to the first memory variable based on the WAR pattern information. It may include a step (S520) of inserting a code replacing the variable.

도 6은 본 발명의 다른 일 실시 예에 따른 멱등 커널 생성 방법을 나타내는 흐름도이다.6 is a flowchart illustrating a method for generating an idempotent kernel according to another embodiment of the present invention.

도 6에 도시된 멱등 커널 생성 방법은 멱등(Idempotent) 커널 생성 장치에 의해 수행될 수 있다. 예를 들면, 멱등 커널 생성 장치는 그래픽 처리 장치(Graphic Processing Unit, GPU), 중앙 처리 장치(Central Processing Unit, CPU), 또는 위외 연산 장치일 수 있다.The idempotent kernel generating method illustrated in FIG. 6 may be performed by an idempotent kernel generating apparatus. For example, the idempotent kernel generating device may be a graphic processing unit (GPU), a central processing unit (CPU), or an out-of-state arithmetic unit.

도 6을 참조하면, 멱등(Idempotent) 커널 생성 방법은, GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인하는 단계(S610)와, 제1 메모리 변수에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입하는 단계(S620)와, GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 제1 메모리 변수로 초기화하는 단계(S630)와, 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입하는 단계(S640)를 포함할 수 있다. 제1 메모리 변수 및 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.Referring to FIG. 6, the idempotent kernel generation method includes a step (S610) of checking a first memory variable related to a write after read (WAR) risk that is not statically determined in the source code related to the GPU kernel function (S610), Inserting a code for setting an access flag bitmap for tracking read access or write access to the first memory variable (S620), declares a temporary pointer variable in the GPU kernel function as a local variable, and the first memory variable (S630) and inserting a code for dynamically determining whether to use the temporary pointer variable as the first memory variable or the second memory variable after read access to the temporary pointer variable and before the write access occurs (S640) ) may be included. The first memory variable and the second memory variable may be global memory variables.

예를 들면, 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 변수들은 조건문 또는 동적으로 결정되는 인덱스와 관련된 변수들일 수 있다. 그리고/또는, 멱등 커널 생성 장치는 RAW 패턴 유무를 추적함으로써, 코드 순서가 아닌 실제 접근에 따른 WAR 위험을 확인할 수 있다.For example, variables related to a write after read (WAR) risk that are not statically determined may be variables related to a conditional statement or a dynamically determined index. And/or, the idempotent kernel generator can check the WAR risk according to the actual access rather than the code order by tracking the existence of RAW patterns.

접근 플래그 비트맵은 글로벌 메모리에 포함되는 영역들 각각에 대한 쓰기 접근 또는 읽기 접근을 나타내는 비트(bit) 집합일 수 있다. 비트 집합의 각 비트는 글로벌 메모리에 포함되는 서로 다른 영역에 매핑될 수 있다.The access flag bitmap may be a set of bits indicating write access or read access to each of the regions included in the global memory. Each bit of the bit set may be mapped to a different region included in the global memory.

접근 플래그 비트맵을 설정하는 코드는 글로벌 메모리에 포함되는 특정 영역에 읽기 접근 또는 쓰기 접근이 발생한 경우, 특정 영역에 매핑되는 비트가 '1'의 값을 갖도록 할 수 있다. 일 실시 예에 따라, 특정 영역에 매핑되는 비트는 읽기 접근과 관련된 비트 및/또는 쓰기 접근과 관련된 비트를 포함할 수 있다. 예를 들면, 읽기 접근이 발생한 경우, 읽기 접근과 관련된 비트는 '1'의 값을 갖고, 쓰기 접근이 발생한 경우, 쓰기 접근과 관련된 비트는 '1'의 값을 갖을 수 있다.The code for setting the access flag bitmap may cause the bit mapped to the specific area to have a value of '1' when a read access or write access occurs to a specific area included in the global memory. According to an embodiment, the bit mapped to the specific region may include a bit related to a read access and/or a bit related to a write access. For example, when a read access occurs, a bit related to a read access may have a value of '1', and when a write access occurs, a bit related to a write access may have a value of '1'.

본 발명의 멱등 커널 생성 방법은 도 5에 도시된 멱등 커널 생성 방법과, 도 6에 도시된 멱등 커널 생성 방법으로 구분하여 기술하였으나, 상술한 도 5의 멱등 커널 생성 방법의 전부 및/또는 일부 구성과, 도 6의 멱등 커널 생성 방법의 전부 및/또는 일부 구성을 조합 및/또는 치환한 멱등 커널 생성 방법도 가능하다.The method for generating an idempotent kernel of the present invention has been described as being divided into the method for generating an idempotent kernel shown in FIG. 5 and the method for generating an idempotent kernel shown in FIG. 6, but all and/or part of the method for generating the idempotent kernel shown in FIG. And, an idempotent kernel generating method in which all and/or some configurations of the idempotent kernel generating method of FIG. 6 are combined and/or substituted is also possible.

이를 통해, 본 발명은 GPU를 활용한 실시간 시스템에서의 우선순위 스케줄링을 보장할 수 있다.Through this, the present invention can ensure priority scheduling in a real-time system using GPU.

또한, 본 발명은 체크포인팅 기술로 활용되어, 점차 증가되고 있는 GPU를 활용한 대규모 시스템에서 장해 허용 시스템(Fault tolerant)을 구축 가능하도록 할 수 있다.In addition, the present invention can be utilized as a checkpointing technology to enable the establishment of a fault tolerant system in a large-scale system using GPUs, which are gradually increasing.

또한, 본 발명은 GPU를 활용한 클라우드 컴퓨팅 환경에서 동작 중인 GPU 커널을 포함하고, 즉각적인 스케줄링을 지원하여 서비스의 QoS 보장 시스템을 구축 가능하도록 할 수 있다. In addition, the present invention may include a GPU kernel operating in a cloud computing environment utilizing GPU, and support immediate scheduling to build a QoS guarantee system for a service.

도 7은 본 명세서에서 제안하는 일 실시 예에 따른 멱등 커널 생성 장치를 나타내는 도면이다.7 is a diagram illustrating an apparatus for generating an idempotent kernel according to an embodiment proposed in the present specification.

도 7을 참조하면, 멱등 커널 생성 장치(700)는 패턴 생성부(701)와, 리다이렉션부(702)를 포함할 수 있다.Referring to FIG. 7 , the idempotent kernel generating apparatus 700 may include a pattern generating unit 701 and a redirection unit 702 .

패턴 생성부(701)는 GPU 커널함수와 관련된 소스 코드로부터 WAR(Write After Read) 패턴 정보를 생성할 수 있다. 멱등 커널 생성 장치(700)는 GPU 특정 지시자에 의해 커널함수와 디바이스 함수를 확인(또는, 구분)할 수 있다.The pattern generator 701 may generate write after read (WAR) pattern information from source code related to the GPU kernel function. The idempotent kernel generating apparatus 700 may identify (or distinguish) the kernel function and the device function according to the GPU specific indicator.

패턴 생성부(701)는, 소스 코드에서 GPU 커널함수를 확인하고, GPU 커널함수에 전달되는 글로벌 메모리 변수를 확인하며, GPU 커널함수 및 글로벌 메모리 변수에 기초하여 WAR 패턴 정보를 생성할 수 있다.The pattern generator 701 may check the GPU kernel function from the source code, check the global memory variable transmitted to the GPU kernel function, and generate WAR pattern information based on the GPU kernel function and the global memory variable.

패턴 생성부(701)는, GPU 커널함수 및 글로벌 메모리 변수와 관련된 연산자를 통해 읽기 접근 및 쓰기 접근을 확인하고, 글로벌 메모리 변수에 대한 읽기 접근과 쓰기 접근에 의해 WAR 패턴 정보를 생성할 수 있다.The pattern generator 701 may check read access and write access through an operator related to the GPU kernel function and global memory variable, and generate WAR pattern information by read access and write access to the global memory variable.

리다이렉션부(702)는 WAR 패턴 정보에 기초하여 제1 메모리 변수에 대한 WAR 위험이 발생하는 읽기 접근 후 쓰기 접근이 확인된 경우, 쓰기 접근에 대한 코드 전에, 제1 메모리 변수를 제2 메모리 변수로 치환하는 코드를 삽입할 수 있다. 제1 메모리 변수 및 상기 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.The redirection unit 702 converts the first memory variable to the second memory variable before the code for the write access when the write access is confirmed after the read access where the WAR risk to the first memory variable occurs based on the WAR pattern information. Substitution code can be inserted. The first memory variable and the second memory variable may be global memory variables.

도 7에 도시된 멱등 커널 생성 장치의 동작 방법은 도 5를 참조하여 설명한 멱등 커널 생성 방법과 동일하므로, 이외 상세한 설명은 생략한다.Since the operation method of the apparatus for generating an idempotent kernel shown in FIG. 7 is the same as the method for generating an idempotent kernel described with reference to FIG. 5 , a detailed description other than that is omitted.

도 8은 본 명세서에서 제안하는 다른 일 실시 예에 따른 멱등 커널 생성 장치를 나타내는 도면이다.8 is a diagram illustrating an apparatus for generating an idempotent kernel according to another embodiment proposed in the present specification.

도 8을 참조하면, 멱등 커널 생성 장치(800)는 분석부(801)와, 플래그 코드 삽입부(802)와, 변수 선언부(803)와, 결정 코드 삽입부(804)를 포함할 수 있다.Referring to FIG. 8 , the idempotent kernel generating apparatus 800 may include an analysis unit 801 , a flag code insertion unit 802 , a variable declaration unit 803 , and a decision code insertion unit 804 . .

분석부(801)는 GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인할 수 있다.The analyzer 801 may identify a first memory variable related to a write after read (WAR) risk that is not statically determined in the source code related to the GPU kernel function.

플래그 코드 삽입부(802)는, 제1 메모리 변수에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입할 수 있다.The flag code insertion unit 802 may insert a code for setting an access flag bitmap for tracking read access or write access to the first memory variable.

변수 선언부(803)는, GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 제1 메모리 변수로 초기화할 수 있다.The variable declaration unit 803 may declare a temporary pointer variable in the GPU kernel function as a local variable and initialize it as a first memory variable.

결정 코드 삽입부(804)는, 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입할 수 있다. 제1 메모리 변수 및 제2 메모리 변수는 글로벌 메모리 변수일 수 있다.The decision code inserting unit 804 may insert a code for dynamically determining whether to use the temporary pointer variable as the first memory variable or the second memory variable after a read access to the temporary pointer variable and before a write access occurs. The first memory variable and the second memory variable may be global memory variables.

정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 변수들은 조건문 또는 동적으로 결정되는 인덱스와 관련된 변수들일 수 있다.Variables related to a write after read (WAR) risk that are not statically determined may be variables related to a conditional statement or a dynamically determined index.

접근 플래그 비트맵은 글로벌 메모리에 포함되는 영역들 각각에 대한 쓰기 접근 또는 읽기 접근을 나타내는 비트(bit) 집합일 수 있다. 비트 집합의 각 비트는 글로벌 메모리에 포함되는 서로 다른 영역에 매핑될 수 있다.The access flag bitmap may be a set of bits indicating write access or read access to each of the regions included in the global memory. Each bit of the bit set may be mapped to a different region included in the global memory.

접근 플래그 비트맵을 설정하는 코드는 글로벌 메모리에 포함되는 특정 영역에 읽기 접근 또는 쓰기 접근이 발생한 경우, 특정 영역에 매핑되는 비트가 '1'의 값을 갖도록 할 수 있다.The code for setting the access flag bitmap may cause the bit mapped to the specific area to have a value of '1' when a read access or write access occurs to a specific area included in the global memory.

도 8에 도시된 멱등 커널 생성 장치의 동작 방법은 도 6을 참조하여 설명한 멱등 커널 생성 방법과 동일하므로, 이외 상세한 설명은 생략한다.Since the operation method of the apparatus for generating an idempotent kernel shown in FIG. 8 is the same as the method for generating an idempotent kernel described with reference to FIG. 6 , a detailed description other than that is omitted.

본 발명의 멱등 커널 생성 장치는 도 7에 도시된 멱등 커널 생성 장치와, 도 8에 도시된 멱등 커널 생성 장치로 구분하여 기술하였으나, 상술한 도 7의 멱등 커널 생성 장치의 전부 및/또는 일부 구성과, 도 8의 멱등 커널 생성 장치의 전부 및/또는 일부 구성을 조합 및/또는 치환한 멱등 커널 생성 장치도 가능하다,The device for generating an idempotent kernel of the present invention has been described as being divided into the device for generating an idempotent kernel shown in FIG. 7 and the device for generating an idempotent kernel shown in FIG. 8, but all and/or part of the device for generating the idempotent kernel shown in FIG. And, an idempotent kernel generating device in which all and/or some configurations of the idempotent kernel generating device of FIG. 8 are combined and/or substituted is also possible,

이상에서 설명된 실시 예들은 본 발명의 구성요소들과 특징들이 소정 형태로 결합된 것들이다. 각 구성요소 또는 특징은 별도의 명시적 언급이 없는 한 선택적인 것으로 고려되어야 한다. 각 구성요소 또는 특징은 다른 구성요소나 특징과 결합되지 않은 형태로 실시될 수 있다. 또한, 일부 구성요소들 및/또는 특징들을 결합하여 본 발명의 실시 예를 구성하는 것도 가능하다. 본 발명의 실시 예들에서 설명되는 동작들의 순서는 변경될 수 있다. 어느 실시예의 일부 구성이나 특징은 다른 실시 예에 포함될 수 있고, 또는 다른 실시예의 대응하는 구성 또는 특징과 교체될 수 있다. 특허청구범위에서 명시적인 인용 관계가 있지 않은 청구항들을 결합하여 실시 예를 구성하거나 출원 후의 보정에 의해 새로운 청구항으로 포함시킬 수 있음은 자명하다.The embodiments described above are those in which elements and features of the present invention are combined in a predetermined form. Each component or feature should be considered optional unless explicitly stated otherwise. Each component or feature may be implemented in a form that is not combined with other components or features. In addition, it is also possible to configure an embodiment of the present invention by combining some elements and/or features. The order of operations described in embodiments of the present invention may be changed. Some features or features of one embodiment may be included in another embodiment, or may be replaced with corresponding features or features of another embodiment. It is obvious that claims that are not explicitly cited in the claims can be combined to form an embodiment or included as a new claim by amendment after filing.

본 발명에 따른 실시 예는 다양한 수단, 예를 들어, 하드웨어, 펌웨어(firmware), 소프트웨어 또는 그것들의 결합 등에 의해 구현될 수 있다. 하드웨어에 의한 구현의 경우, 본 발명의 일 실시 예는 하나 또는 그 이상의 ASICs(application specific integrated circuits), DSPs(digital signal processors), DSPDs(digital signal processing devices), PLDs(programmable logic devices), FPGAs(field programmable gate arrays), 프로세서, 콘트롤러, 마이크로 콘트롤러, 마이크로 프로세서 등에 의해 구현될 수 있다.Embodiments according to the present invention may be implemented by various means, for example, hardware, firmware, software, or a combination thereof. In the case of implementation by hardware, an embodiment of the present invention provides one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), FPGAs ( field programmable gate arrays), a processor, a controller, a microcontroller, a microprocessor, and the like.

펌웨어나 소프트웨어에 의한 구현의 경우, 본 발명의 일 실시 예는 이상에서 설명된 기능 또는 동작들을 수행하는 모듈, 절차, 함수 등의 형태로 구현될 수 있다. 소프트웨어 코드는 메모리에 저장되어 프로세서에 의해 구동될 수 있다. 상기 메모리는 상기 프로세서 내부 또는 외부에 위치하여, 이미 공지된 다양한 수단에 의해 상기 프로세서와 데이터를 주고 받을 수 있다.In the case of implementation by firmware or software, an embodiment of the present invention may be implemented in the form of modules, procedures, functions, etc. that perform the functions or operations described above. The software code may be stored in the memory and driven by the processor. The memory may be located inside or outside the processor, and may transmit/receive data to and from the processor by various known means.

본 발명은 본 발명의 필수적 특징을 벗어나지 않는 범위에서 다른 특정한 형태로 구체화될 수 있음은 당업자에게 자명하다. 따라서, 상술한 상세한 설명은 모든 면에서 제한적으로 해석되어서는 아니 되고 예시적인 것으로 고려되어야 한다. 본 발명의 범위는 첨부된 청구항의 합리적 해석에 의해 결정되어야 하고, 본 발명의 등가적 범위 내에서의 모든 변경은 본 발명의 범위에 포함된다.It is apparent to those skilled in the art that the present invention may be embodied in other specific forms without departing from the essential characteristics of the present invention. Accordingly, the above detailed description should not be construed as restrictive in all respects but as exemplary. The scope of the present invention should be determined by a reasonable interpretation of the appended claims, and all modifications within the equivalent scope of the present invention are included in the scope of the present invention.

Claims (10)

삭제delete 삭제delete 삭제delete 삭제delete 삭제delete GPU 커널함수와 관련된 소스 코드 내 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 제1 메모리 변수를 확인하는 분석부;
상기 제1 메모리 변수에 대한 읽기 접근 또는 쓰기 접근을 추적하기 위한 접근 플래그 비트맵을 설정하는 코드를 삽입하는 플래그 코드 삽입부;
상기 GPU 커널함수 내 임시 포인터 변수를 지역 변수로 선언하고, 상기 제1 메모리 변수로 초기화하는 변수 선언부; 및
상기 임시 포인터 변수에 대한 읽기 접근 후, 쓰기 접근 발생 전에 동적으로 상기 임시 포인터 변수를 제1 메모리 변수로 할지, 제2 메모리 변수로 할지 결정하는 코드를 삽입하는 결정 코드 삽입부를 포함하는 것을 특징으로 하는 멱등 커널 생성 장치.
an analysis unit that identifies a first memory variable related to a write after read (WAR) risk that is not statically determined in the source code related to the GPU kernel function;
a flag code insertion unit for inserting a code for setting an access flag bitmap for tracking read access or write access to the first memory variable;
a variable declaration unit for declaring a temporary pointer variable in the GPU kernel function as a local variable and initializing it as the first memory variable; and
After read access to the temporary pointer variable, before the write access occurs, it characterized in that it comprises a decision code insertion unit for inserting a code for dynamically determining whether the temporary pointer variable as a first memory variable or a second memory variable An idempotent kernel generator.
제6항에 있어서,
상기 정적으로 결정되지 않는 WAR(Write After Read) 위험과 관련된 변수들은 조건문 또는 동적으로 결정되는 인덱스와 관련된 변수들인 멱등 커널 생성 장치.
7. The method of claim 6,
The variable related to the write after read (WAR) risk that is not statically determined is an idempotent kernel generator that is a variable related to a conditional statement or a dynamically determined index.
제6항에 있어서,
상기 접근 플래그 비트맵은 글로벌 메모리에 포함되는 영역들 각각에 대한 쓰기 접근 또는 읽기 접근을 나타내는 비트(bit) 집합인 멱등 커널 생성 장치.
7. The method of claim 6,
The access flag bitmap is an idempotent kernel generating apparatus that is a set of bits indicating a write access or a read access to each of the regions included in the global memory.
제8항에 있어서,
상기 접근 플래그 비트맵을 설정하는 코드는 상기 글로벌 메모리에 포함되는 특정 영역에 읽기 접근 또는 쓰기 접근이 발생한 경우, 상기 특정 영역에 매핑되는 비트가 1의 값을 갖도록 하는 멱등 커널 생성 장치.
9. The method of claim 8,
The code for setting the access flag bitmap causes a bit mapped to the specific area to have a value of 1 when a read access or a write access occurs to a specific area included in the global memory.
제6항에 있어서,
상기 제1 메모리 변수 및 상기 제2 메모리 변수는 글로벌 메모리 변수인 멱등 커널 생성 장치.
7. The method of claim 6,
wherein the first memory variable and the second memory variable are global memory variables.
KR1020200130289A 2019-06-05 2020-10-08 Idempotent kernel generateing method and apparatus KR102267500B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020200130289A KR102267500B1 (en) 2019-06-05 2020-10-08 Idempotent kernel generateing method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020190066832A KR102201669B1 (en) 2019-06-05 2019-06-05 Idempotent kernel generateing method and apparatus
KR1020200130289A KR102267500B1 (en) 2019-06-05 2020-10-08 Idempotent kernel generateing method and apparatus

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
KR1020190066832A Division KR102201669B1 (en) 2019-06-05 2019-06-05 Idempotent kernel generateing method and apparatus

Publications (2)

Publication Number Publication Date
KR20200140210A KR20200140210A (en) 2020-12-15
KR102267500B1 true KR102267500B1 (en) 2021-06-22

Family

ID=73780374

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020200130289A KR102267500B1 (en) 2019-06-05 2020-10-08 Idempotent kernel generateing method and apparatus

Country Status (1)

Country Link
KR (1) KR102267500B1 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130298106A1 (en) 2012-05-01 2013-11-07 Oracle International Corporation Indicators for resources with idempotent close methods in software programs
WO2015031549A1 (en) 2013-08-30 2015-03-05 Microsoft Corporation Generating an idempotent workflow
US20190155649A1 (en) 2017-11-20 2019-05-23 Microsoft Technology Licensing, Llc Running complex workflows in distributed systems while protecting consistency and ensuring progress despite failures

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101155123B1 (en) * 2010-10-26 2012-06-11 한국과학기술원 Apparatus and method for protecting memory of application from failure of kernel code

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130298106A1 (en) 2012-05-01 2013-11-07 Oracle International Corporation Indicators for resources with idempotent close methods in software programs
WO2015031549A1 (en) 2013-08-30 2015-03-05 Microsoft Corporation Generating an idempotent workflow
US20190155649A1 (en) 2017-11-20 2019-05-23 Microsoft Technology Licensing, Llc Running complex workflows in distributed systems while protecting consistency and ensuring progress despite failures

Also Published As

Publication number Publication date
KR20200140210A (en) 2020-12-15

Similar Documents

Publication Publication Date Title
US10877757B2 (en) Binding constants at runtime for improved resource utilization
US8572573B2 (en) Methods and apparatus for interactive debugging on a non-preemptible graphics processing unit
US10853071B2 (en) Simulation of exclusive instructions
US11030076B2 (en) Debugging method
CN109144515B (en) Off-line simulation method and device for DCS graphical algorithm configuration
US9513911B2 (en) Method of detecting stack overflows and processor for implementing such a method
KR20090084896A (en) Controlling instruction execution in a processing environment
US9645802B2 (en) Technique for grouping instructions into independent strands
US20130254747A1 (en) Method and apparatus for testing programs
CN110781016B (en) Data processing method, device, equipment and medium
US20140215483A1 (en) Resource-usage totalizing method, and resource-usage totalizing device
US11194705B2 (en) Automatically introducing register dependencies to tests
US9395992B2 (en) Instruction swap for patching problematic instructions in a microprocessor
CN117546139A (en) Deterministic replay of multi-line Cheng Zongji on a multi-threaded processor
US20140096147A1 (en) System and method for launching callable functions
KR102267500B1 (en) Idempotent kernel generateing method and apparatus
US9218273B2 (en) Automatic generation of a resource reconfiguring test
JP2019160270A (en) Method, device, server, and program for checking defective function
KR20210028088A (en) Generating different traces for graphics processor code
KR102201669B1 (en) Idempotent kernel generateing method and apparatus
US9038077B1 (en) Data transfer protection in a multi-tasking modeling environment
US11455261B2 (en) First boot with one memory channel
US8554522B2 (en) Detection of design redundancy
US20170132094A1 (en) Technologies for analyzing persistent memory programs
US9021496B2 (en) Method and program for recording object allocation site

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant