approximate code cloning detection method adopting GPU acceleration

A code and detection efficiency technology, applied in the field of approximate code clone detection, can solve problems such as taking 4.5 days, maintaining a high level, detection accuracy and performance difficulties

CN109828785AActive Publication Date: 2019-05-31FUDAN UNIV
10 Cites 3 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Publication Date
2019-05-31

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
Patent Text Reader

Abstract

The invention belongs to the technical field of software code analysis, and particularly relates to an approximate code cloning detection method accelerated by a GPU. According to the invention, source codes of a plurality of software projects are labeled; converting into a string consisting of a tag sequence; constructing the string into a suffix array sorted according to suffix character stringsby adopting a GPU (Graphics Processing Unit) parallel method; and finally, the code cloning fragments which are smaller than the code cloning length threshold but not smaller than the candidate cloning length threshold are sequenced through a GPU parallel acceleration method according to the position in the code file, and whether the cloned fragments can meet the similarity threshold requirementof approximate cloning or not after being merged is calculated. And if the code similarity meets the threshold requirement, recording the code similarity as approximate code cloning. According to themethod, the approximate code clone can be rapidly detected on the code fragment granularity in mass codes.
Need to check novelty before this filing date? Find Prior Art

Description

technical field

[0001] The invention belongs to the technical field of software code analysis, and in particular relates to an approximate code clone detection method accelerated by GPU. Background technique

[0002] Code clone detection is a technique to find duplicate identical or similar code fragments from software source code. As early as the 1990s, researchers noticed the repetitive nature of software code. Code duplication or code cloning generally falls into four types. Type I (Type-1) clone refers to the exact same code fragment. Type II (Type-2) clones are parameterized similar codes that are identical except for identifiers, constants, and types. Type III (Type-3) clones refer to similar codes that have additions, deletions, or other modifications beyond Type II clones. Type IV (Type-4) cloning refers to codes with similar semantics, that is, the grammatical structure may be completely different, but the codes have similar semantics. Among the code clone dete...

Examples

Embodiment Construction

[0030] Through the following description of the embodiments of the present invention combined with the accompanying drawings, the purpose, specific operation methods and advantages of the present invention can be further understood.

[0031] figure 2 An example of the procedure for detecting type III close clones in the three methods m1, m2, m3. The present invention labels all the source codes (including methods m1, m2, m3) to form a label string ① established in order by all the labels in the code, wherein the methods m1, m2, m3 are represented as three strips. Subsequently, the present invention constructs the label string into a suffix array ② by adopting GPU parallel acceleration according to character strings. Wherein, each element n represents a suffix string, and the suffix string starts from the nth tag of the tag string to the end of the tag string of the entire code. If the suffix strings represented by two adjacent elements have the same prefix (that is, several...