Methods, apparatus, electronic devices, and readable storage media for determining k target values.

By dividing the dataset into blocks for parallel computation, candidate data blocks and rows are selected, solving the problem of excessive serial operations in traditional Top-K query methods in parallel computing environments, and achieving efficient parallel computation and excellent performance.

CN122086941APending Publication Date: 2026-05-26YUAN LI (BEI JING) BAN DAO TI JI SHU YOU XIAN GONG SI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
YUAN LI (BEI JING) BAN DAO TI JI SHU YOU XIAN GONG SI
Filing Date
2025-12-29
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In parallel computing environments, traditional Top-K query methods cannot effectively utilize the parallel computing capabilities of multi-core processors or parallel computing architectures due to their serial dependency, resulting in low utilization of computing resources and difficulty in meeting the needs of application scenarios with high real-time requirements.

Method used

The input dataset is divided into multiple data blocks. Candidate data blocks and data rows are selected based on the local extrema of the blocks obtained by parallel computing. K target values ​​are determined through a two-level selection mechanism, which is then transformed into a fully parallel extremum comparison operation.

Benefits of technology

It significantly reduces computational complexity, increases processing throughput, optimizes memory access efficiency, reduces bandwidth requirements, and achieves excellent performance on large-scale data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086941A_ABST
    Figure CN122086941A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, electronic device, and readable storage medium for determining k target values. First, the input dataset is divided into multiple data blocks. Based on the local extrema of each data block obtained through parallel computation, k candidate data blocks are selected. According to the block indices of the k candidate data blocks, their internal data rows are obtained, and based on the local extrema of each data row obtained through parallel computation, k candidate data rows are selected. Finally, the data is obtained according to the row indices of the k candidate data rows, and k target values ​​are determined. This scheme transforms traditional serial heap operations into fully parallelizable extremum comparison operations through block division and a two-level selection mechanism, reducing computational complexity. This design enables efficient parallel execution of computational tasks on multiple processors, improving processing throughput. Simultaneously, the index supports batch data retrieval mechanisms, optimizing memory access efficiency and reducing bandwidth requirements, thereby achieving excellent performance in scenarios with data volumes much larger than k.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data processing and parallel computing technology, specifically relating to a method for determining k target values ​​in a parallel computing environment, a device for determining k target values ​​in a parallel computing environment, an electronic device, and a readable storage medium. Background Technology

[0002] In fields such as data processing, machine learning, and scientific computing, there is often a need to quickly find the K largest (or smallest) values ​​from large-scale datasets, i.e., the Top-K (top-K sampling) query problem. With the explosive growth of data scale, it has become difficult to meet the needs of application scenarios with high real-time requirements.

[0003] Traditionally, in single-core CPU environments, a min-heap structure is often used to solve the Top-K problem. This method maintains a min-heap of size K, and stores the current K largest elements by traversing the data and dynamically adjusting the heap structure. However, each insertion and adjustment of the heap structure requires serial comparison of parent and child nodes. This inherent serial dependency makes it impossible to effectively utilize the parallel computing capabilities of modern multi-core processors or parallel computing architectures (such as SIMD (Single Instruction Multiple Data) instruction sets). Even with block merge sorting, its local sorting or heap adjustment phases still involve a large number of serial operations that are difficult to parallelize, failing to fully utilize instruction-level parallel architectures such as SIMD. Summary of the Invention

[0004] The purpose of this application is to provide a method for determining k target values ​​in a parallel computing environment, a device for determining k target values ​​in a parallel computing environment, an electronic device, and a readable storage medium, which can solve the problems of Top-K query problems requiring serial processing, having a large number of serial operations that are difficult to parallelize, low utilization of computing resources, and insufficient parallel efficiency.

[0005] To solve the above-mentioned technical problems, this application is implemented as follows: In a first aspect, embodiments of this application provide a method for determining k target values ​​in a parallel computing environment, the method comprising: Divide the input dataset into multiple data blocks; Based on the local extrema of each data block obtained by parallel computing, the k candidate data blocks are selected. Based on the block index of the k candidate data blocks, the data rows in the candidate data blocks are obtained, and the k candidate data rows are selected based on the row local extrema of each obtained data row obtained by parallel computing. Based on the row index of the k candidate data rows, the data in the candidate data rows is obtained, and the k target values ​​are determined based on the obtained data.

[0006] Optionally, obtaining the data rows in the candidate data blocks based on the block indices of the k candidate data blocks includes: Based on the k block indices, generate the first batch retrieval instructions; Execute the first batch acquisition instruction to acquire data rows from the k candidate data blocks in parallel.

[0007] Optionally, before retrieving the data from the candidate data rows based on the row indices of the k candidate data rows, the method further includes: Based on the block index of the candidate data block and the position number of the data row within it, calculate the row index that represents the global position of the candidate data row in the input dataset.

[0008] Optionally, obtaining the data in the candidate data rows based on the row indices of the k candidate data rows includes: Based on the k row indices, generate a second batch retrieval instruction; The second batch acquisition instruction is executed to acquire data from the k candidate data rows in parallel.

[0009] Optionally, after determining the k target values ​​based on the acquired data, the method further includes: Based on the row index of the candidate data row and the position number of the data column within it, calculate the target value index, which represents the global position of the target value in the input dataset; Output the k target values ​​and their corresponding target value indices.

[0010] Optionally, dividing the input dataset into multiple data blocks includes: The size of each data block is determined based on the single data processing capability of the parallel computing unit. The input dataset is divided into multiple data blocks based on the size of each data block.

[0011] Optionally, dividing the input dataset into multiple data blocks according to the size of each data block includes: The input dataset is divided into multiple data blocks according to the target data block size; If the total amount of data n in the input dataset cannot be divided evenly by the size of the target data block, then n is aligned by filling in invalid data values; wherein, the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

[0012] Secondly, embodiments of this application provide a device for determining k target values ​​in a parallel computing environment, the device comprising: The partitioning module is used to divide the input dataset into multiple data blocks; The first filtering module is used to filter out the k candidate data blocks based on the local extrema of each data block obtained by parallel computing. The second filtering module is used to obtain data rows in the candidate data blocks according to the block index of the k candidate data blocks, and filter out the k candidate data rows based on the row local extrema of each obtained data row obtained by parallel computing. The determination module is used to obtain data in the candidate data rows according to the row index of the k candidate data rows, and determine the k target values ​​based on the obtained data.

[0013] Optionally, the second filtering module includes: The first instruction generation submodule is used to generate a first batch retrieval instruction based on the k block indices; The first instruction execution submodule is used to execute the first batch acquisition instruction to acquire data rows from the k candidate data blocks in a parallel manner.

[0014] Optionally, the device further includes: The row index calculation module is used to calculate the row index representing the global position of the candidate data row in the input dataset based on the block index of the candidate data block and the position number of the data row within it, before obtaining the data in the candidate data row according to the row index of the k candidate data rows.

[0015] Optionally, the determining module includes: The second instruction generation submodule is used to generate a second batch retrieval instruction based on the k row indices; The second instruction execution submodule is used to execute the second batch acquisition instruction to acquire data from the k candidate data rows in a parallel manner.

[0016] Optionally, the device further includes: The index calculation module is used to calculate the target value index, which represents the global position of the target value in the input dataset, based on the row index of the candidate data row and the position number of the data column inside it, after the k target values ​​are determined based on the acquired data. The index output module is used to output the k target values ​​and their corresponding target value indices.

[0017] Optionally, the partitioning module includes: Determine the submodule, which is used to determine the size of each data block based on the single data processing capability of the parallel computing unit; The partitioning submodule is used to divide the input dataset into multiple data blocks according to the size of each data block.

[0018] Optionally, the sub-module division includes: A partitioning unit is used to divide the input dataset into multiple data blocks according to the target data block size; A padding unit is used to align n by padding with invalid data values ​​if the total amount of data n in the input dataset cannot be divided evenly by the size of the target data block; wherein the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

[0019] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0020] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0021] According to the embodiments of this application, the input dataset is first divided into multiple data blocks. Then, based on the local extrema of each data block obtained through parallel computing, k candidate data blocks are selected, completing the first level of selection. Next, based on the block indices of the k candidate data blocks, their internal data rows are obtained, and based on the local extrema of each data row obtained through parallel computing, k candidate data rows are selected, achieving the second level of precise selection. Finally, data is obtained based on the row indices of the k candidate data rows, and k target values ​​are determined. This scheme, through block division and a two-level selection mechanism, transforms traditional serial heap operations into fully parallel extremum comparison operations, significantly reducing computational complexity. This design enables efficient parallel execution of computational tasks on multiple processors, greatly improving processing throughput. Simultaneously, the index supports batch data retrieval mechanisms, optimizing memory access efficiency and reducing bandwidth requirements, thereby achieving excellent performance in scenarios with data volumes far exceeding k. Attached Figure Description

[0022] Figure 1 This is a flowchart illustrating the steps of a method for determining k target values ​​in a parallel computing environment, as provided in an embodiment of this application. Figure 2 This is a diagram illustrating data segmentation; Figure 3 This is a schematic diagram illustrating the principle behind determining k target values; Figure 4 This is a structural block diagram of an embodiment of a device for determining k target values ​​in a parallel computing environment provided in another embodiment of this application; Figure 5 This is a structural block diagram of an electronic device for determining k target values, according to an exemplary embodiment. Detailed Implementation

[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0025] The method for determining k target values ​​for a parallel computing environment provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0026] The method for determining k target values ​​applicable to parallel computing architectures described in this application can be executed by servers, data centers, high-performance computing clusters, or other computing devices equipped with parallel computing units (such as GPUs and multi-core CPUs), and this application does not impose specific limitations on this. This method is particularly suitable for large-scale data processing scenarios with high requirements for processing speed and real-time performance.

[0027] For example, in recommendation systems and advertising, this method can be used to filter the Top-K results most likely to interest a user from hundreds of millions of products or content in real time, thereby achieving precise targeting. In financial risk control and high-frequency trading, this method can help identify the K highest-risk trades or the K most profitable investment opportunities from massive amounts of market data or transaction flows within milliseconds. Furthermore, in large-scale machine learning and scientific computing, this method can efficiently process the massive amounts of data generated by model inference or simulation, quickly filtering out key features or results, significantly accelerating the decision-making and analysis process.

[0028] Reference Figure 1The diagram illustrates a flowchart of a method for determining k target values ​​in a parallel computing environment, provided by an embodiment of this application. Specifically, the method may include the following steps: Step 101: Divide the input dataset into multiple data blocks.

[0029] In this application embodiment, a parallel computing environment refers to a complete computing system composed of hardware, software, and programming models designed for efficient execution of parallel computing tasks. Its core objective is to decompose a large-scale complex problem into multiple sub-tasks that can be processed simultaneously, significantly reducing computation time through collaboration.

[0030] For example, as a typical example of a parallel computing environment, the SIMD architecture is a computing system that allows a single controller to manage multiple processing units synchronously, enabling all active units to execute the same instructions within the same clock cycle, but each operating on different data streams.

[0031] In this embodiment, extreme values ​​include both maximum and minimum scenarios. By adjusting the comparison logic, the same architecture can simultaneously support top-k maximum and top-k minimum queries. For example, when searching for the largest k numbers, maximum value comparison is used, and when searching for the smallest k numbers, minimum value comparison is used.

[0032] In this embodiment, the input dataset refers to the original data set to be processed, containing n numerical elements. In a parallel computing environment, n is typically a very large value (e.g., millions or more).

[0033] In this embodiment, a large-scale input dataset is divided into multiple subsets (blocks) according to a specific dimension, with each block containing x rows and y columns of data. The block partitioning strategy is the foundation of parallel computing.

[0034] For example, such as Figure 2 The diagram shows a breakdown of the data blocks. Figure 2 The displayed block partitioning method allows each data block to be processed independently.

[0035] In this embodiment, the computational task is decomposed into independent subtasks by partitioning, adapting to the distributed processing characteristics of parallel computing architectures. For example, the number of partitions is determined based on the number of processor cores.

[0036] Step 102: Based on the local extrema of each data block obtained by parallel computing, select the k candidate data blocks.

[0037] In this application's embodiments, parallel computing refers to decomposing a complex task into multiple subtasks, which are executed simultaneously on multiple processors or computing units. This application fully utilizes spatial parallelism, that is, using multiple processors to perform computations concurrently.

[0038] For example, on a GPU with 1000 cores, it is possible to process extremum calculation tasks of 1000 data blocks simultaneously.

[0039] In the embodiments of this application, the local extremum of a block refers to the maximum or minimum value in each data block.

[0040] In this embodiment, the k data blocks most likely to contain the global k target values, selected through block local extremum comparison, are called candidate data blocks. By utilizing the transitivity of extremum comparison, it is ensured that the global k target values ​​are necessarily contained within the k data blocks with the largest local extrema.

[0041] In practice, the extreme values ​​(maximum or minimum values) of each data block are calculated in parallel. The m extreme values ​​are sorted. The data blocks corresponding to the top k extreme values ​​are selected as candidate data blocks.

[0042] Step 103: Based on the block index of the k candidate data blocks, obtain the data rows in the candidate data blocks, and filter out the k candidate data rows based on the row local extrema of each obtained data row obtained by parallel computing.

[0043] In this embodiment, the block index is used to uniquely identify the position number of each data block in the input dataset. For example, a block index of 15 indicates that the block is the 15th data block in the input dataset.

[0044] In this embodiment, the block indices of the k candidate data blocks determined above are recorded. Data rows can be retrieved in batches based on the block indices. Each data block contains multiple rows of data, and the row index is used to locate the global position of the data in the input dataset.

[0045] In the embodiments of this application, row local extrema refer to the maximum or minimum value in each data row.

[0046] In this embodiment, the k data rows most likely to contain the global k target values, selected through row local extremum comparison, are called candidate data rows. By utilizing the transitivity of extremum comparison, it is ensured that the global k target values ​​are necessarily contained within the k data rows with the largest local extrema.

[0047] In practice, the extreme values ​​(maximum or minimum values) of each data row are calculated in parallel. The m extreme values ​​are sorted. The data rows corresponding to the top k extreme values ​​are selected as candidate data rows.

[0048] For example, from 200 rows in 10 candidate data blocks (each containing 20 rows), select the 10 data rows with the largest extreme values ​​(k=10).

[0049] Step 104: Obtain the data in the candidate data rows according to the row index of the k candidate data rows, and determine the k target values ​​based on the obtained data.

[0050] In this embodiment of the application, the target value is the k extreme values ​​(maximum or minimum values) that need to be found.

[0051] In this embodiment, the row indices of the k candidate data rows determined above are recorded. Data can be retrieved in batches based on the row indices. Each data row contains multiple data items.

[0052] In this embodiment, multiple data points in k candidate data rows are sorted or heap-adjusted to output k target values. For example, from 500 values ​​in 10 candidate rows (50 data points per row), the final topk=10 target values ​​are determined.

[0053] For example, such as Figure 3 This diagram illustrates the principle behind determining the k target values. The multiple data blocks on the left, each with x rows and y columns, represent the initial state of "dividing the input dataset into multiple data blocks." The process proceeds through an intermediate aggregation stage, with the total data volume labeled k×x×y. This visually corresponds to the step of "extracting data rows from k candidate data blocks and filtering out k candidate data rows," demonstrating how a two-level filtering process drastically reduces the range of data to be processed from the original total. Finally, the data is further condensed into a k×y region on the right, representing the final dataset to be computed from the k candidate data rows, thereby efficiently determining the "k target values." The entire diagram clearly reveals how the hierarchical process of "blocking → filtering → aggregation" significantly compresses the final data size requiring sorting, thus achieving a significant efficiency improvement in a parallel computing environment.

[0054] According to the embodiments of this application, the input dataset is first divided into multiple data blocks. Then, based on the local extrema of each data block obtained through parallel computing, k candidate data blocks are selected, completing the first level of selection. Next, based on the block indices of the k candidate data blocks, their internal data rows are obtained, and based on the local extrema of each data row obtained through parallel computing, k candidate data rows are selected, achieving the second level of precise selection. Finally, data is obtained based on the row indices of the k candidate data rows, and k target values ​​are determined. This scheme, through block division and a two-level selection mechanism, transforms traditional serial heap operations into fully parallel extremum comparison operations, significantly reducing computational complexity. This design enables efficient parallel execution of computational tasks on multiple processors, greatly improving processing throughput. Simultaneously, the index supports batch data retrieval mechanisms, optimizing memory access efficiency and reducing bandwidth requirements, thereby achieving excellent performance in scenarios with data volumes far exceeding k.

[0055] In one optional embodiment of this application, the step of obtaining data rows in the candidate data blocks according to the block indexes of the k candidate data blocks includes: generating a first batch acquisition instruction according to the k block indexes; and executing the first batch acquisition instruction to obtain data rows in the k candidate data blocks in parallel.

[0056] Each block index corresponds to the starting position and size information of a data block. The block index provides the processor with a precise basis for memory address calculation.

[0057] Batch fetch instructions are processor instructions specifically designed to optimize memory access patterns in parallel computing. Their core idea is to combine multiple discrete, non-contiguous memory address access requests into a single instruction for execution, thereby enabling the simultaneous and parallel fetching of multiple data elements from memory.

[0058] For example, in the SIMD architecture, the Embedding instruction accepts a base address, an offset vector (i.e., an index list), and a mask as operands. It calculates the actual address of each data item based on the base address plus the offset [i], then reads the data from these discrete addresses in parallel and packs them into a vector register.

[0059] After selecting k candidate data blocks, the first batch retrieval instruction is generated and executed based on the index of these k blocks, and all data rows in these candidate blocks are retrieved in parallel.

[0060] The parallel acquisition mechanism involves reading multiple data blocks simultaneously, unlike the traditional serial block-by-block reading method. This mechanism fully utilizes the multi-channel characteristics of the memory subsystem.

[0061] For example, reading data from 5 scattered memory locations requires 5 clock cycles in a serial manner, while parallel acquisition can be completed in 1-2 cycles.

[0062] The core of converting a discrete list of block indices into parallel operation instructions that can be executed by the processor lies in address calculation and instruction encoding.

[0063] In practice, the starting address of each data block is calculated based on the block index: Address = Base Address + Block Index × Block Size. The k address information is encoded into operands for a single batch fetch instruction. The instruction decoder recognizes the semantics of parallel operations and activates multiple memory controllers.

[0064] The hardware execution flow for parallel fetching utilizes the non-uniform memory access architecture of modern processors to simultaneously initiate read requests to multiple memory channels. The instruction dispatch unit broadcasts parallel fetching instructions to each memory controller, each controller independently processes the specified block read task, the memory arbitrator coordinates concurrent access across memory banks, and the data collection unit integrates the results returned by each channel.

[0065] Based on the k block indices, a first batch fetch instruction is generated. Executing this instruction enables parallel fetching of data rows from multiple candidate data blocks. This parallel fetching mechanism allows the originally serial memory access operations to overlap in time, effectively reducing the processor's idle waiting time. Simultaneously, the batch data access mode improves the spatial locality of memory access, thereby significantly increasing the cache hit rate. Furthermore, the computing unit can schedule and execute other computing tasks while waiting for the batch data to return, allowing for full overlap and utilization of the processor's internal computing resources and memory access resources, ultimately achieving an effective improvement in the overall system resource utilization. In one optional embodiment of this application, before obtaining the data in the candidate data row according to the row index of the k candidate data rows, the method further includes: calculating the row index representing the global position of the candidate data row in the input dataset according to the block index of the candidate data block and the position number of the data row within it.

[0066] The position number of a data row refers to its relative position within its data block. It is typically a consecutive integer starting from 0 and is used to identify the row's order within the block. The position number provides local location within the block and, together with the block index, constitutes complete global location information.

[0067] For example, in a data block with block index 5, position number 3 indicates that this is the 4th row of data in the block (assuming numbering starts from 0).

[0068] Global location refers to the absolute address of a data row within the input dataset, ensuring that the specific data can be uniquely and accurately located.

[0069] By leveraging the regularity of the block structure, local location information is mapped to the global address space through linear transformation.

[0070] In practice, a fixed number of rows x is determined for each data block. The block index is converted to the base address of the row index using multiplication: base address = block index × x. Local location information is then integrated using addition: row index = base address + position number.

[0071] For example, if x=8 (8 rows per block) and the candidate block index is [2,5,7], and we need to obtain the 3rd row of each block (position number = 2), then the row index is calculated as follows: 2×8+2=18, 5×8+2=42, 7×8+2=58.

[0072] Based on the block index of the candidate data block and the position number of its internal data rows, a row index representing the global position of the candidate data row in the input dataset is calculated. This calculation process establishes a precise positional mapping relationship from the filtered candidate data blocks to the original dataset by performing a linear mapping transformation on the block index and the position number. Since the calculation of each row index is independent and follows a unified algorithm, it supports fully parallel computation of k×x row indices. This parallelized index calculation mechanism effectively reduces the latency caused by sequential execution and significantly improves the overall computational efficiency of the position mapping stage.

[0073] In one optional embodiment of this application, obtaining data from the candidate data rows based on the row indices of the k candidate data rows includes: generating a second batch retrieval instruction based on the k row indices; and executing the second batch retrieval instruction to retrieve data from the k candidate data rows in parallel.

[0074] After selecting k candidate data rows, a second batch retrieval instruction is generated and executed based on the index of these k rows to retrieve the specific data values ​​in these candidate rows in parallel for final calculation.

[0075] A row index is a calculated global location identifier that uniquely determines the exact location of a data row within the original input dataset. The row index provides precise memory address parameters for the second batch fetch instructions; each row index corresponds to the starting address of a data row.

[0076] Candidate data acquisition refers to extracting specific numerical data from candidate data rows. This data is the foundation for the final top-k calculation. Each candidate data row contains y data values, and k candidate data rows contain a total of k×y data points to be processed.

[0077] For example, 5 × 32 = 160 data values ​​need to be obtained from 5 candidate data rows (each row contains 32 data points) for final filtering.

[0078] The core of converting a discrete list of row indices into parallel load instructions that the processor can recognize lies in address calculation and instruction encoding optimization.

[0079] In practice, the starting address of each data row is calculated based on the row index: Row address = Base address + Row index × Row size. Address validity is verified to ensure no out-of-bounds access. The k row addresses are encoded into an operand vector for a batch fetch instruction. The instruction register loads the parallel opcode and address parameters.

[0080] The second batch retrieval command is similar to the first batch retrieval command, except that the data retrieved is different.

[0081] A second batch retrieval instruction is generated based on the k row indices. By executing this instruction, the read operation that originally required k serial executions is merged into a single parallel batch retrieval, realizing the synchronous extraction of data from candidate data rows. This parallel retrieval mechanism effectively overcomes the latency accumulation effect of sequential access, significantly improves the computational throughput of the data retrieval stage, and thus enhances the time efficiency of the overall processing flow.

[0082] In one optional embodiment of this application, after determining the k target values ​​based on the acquired data, the method further includes: calculating a target value index that represents the global position of the target value in the input dataset according to the row index of the candidate data row and the position number of the data column within it; and outputting the k target values ​​and their corresponding target value indices.

[0083] The column position number refers to the column position number of the target value within its data row. It is usually a consecutive integer starting from 0 and is used to identify the specific position of the value within the row. The position number provides precise location within the row and, together with the row index, constitutes complete global location information.

[0084] For example, in a data row with row index 153, position number 7 indicates the 8th data value in that row.

[0085] The target value index is a unique identifier obtained through calculation, which can accurately represent the absolute storage location of each target value in the original input dataset.

[0086] By leveraging the row-first principle of data storage, a linear transformation is used to convert two-dimensional coordinates (row index, column number) into a one-dimensional global index.

[0087] In practice, a fixed number of columns y is determined for each row (as described in the documentation for the block size). The row index is converted to a base address using multiplication: base address = row index × y. Column location information is then integrated using addition: target value index = base address + column number.

[0088] The indexes of the k target values ​​can be computed independently and in parallel, while boundary validity verification is performed simultaneously. The numerical results are packaged with location information and output to provide a complete and usable query result. Not only are the top k numerical results output, but also the corresponding global location information, forming a complete query result.

[0089] Based on the row index of the candidate data rows and the position sequence number of their internal data columns, a target value index representing the global position of the target value in the input dataset is calculated. This calculation process establishes a precise positional mapping relationship from the filtering results to the original data elements through linear mapping, thereby directly providing global positioning information of the target value and avoiding repeated position calculation operations in downstream processing. A complete pair of k target values ​​and their corresponding target value indices is output, providing a holistic query result combining numerical and positional information, supporting real-time verification and source analysis of the query results. Since the calculation of each target value index is independent, this process supports fully parallel execution, and the index calculation stage achieves an acceleration effect proportional to the number of target values, k.

[0090] In one optional embodiment of this application, the input dataset is divided into multiple data blocks, including: determining the size of each data block based on the single data processing capability of the parallel computing unit; and dividing the input dataset into multiple data blocks according to the size of each data block.

[0091] Parallel computing units refer to the amount of data that a hardware unit (such as a GPU stream processor or a CPU core) can efficiently process in a single operation. This capability is determined by characteristics such as the hardware's memory bandwidth, cache size, and number of registers.

[0092] The block size needs to be matched with the processing characteristics of the computing unit to achieve the best parallel effect.

[0093] For example, a GPU's warp contains 32 threads, and setting the data block size to an integer multiple of 32 (such as y=32 or 64) ensures that the computing unit runs at full capacity.

[0094] Single-cycle data processing capability measures the maximum amount of data that a parallel computing unit can process in a single instruction cycle, and is a direct reflection of hardware parallelism. The goal is to find the optimal balance between hardware processing power and algorithm efficiency, ensuring that each computing unit receives sufficient computational tasks.

[0095] For example, on a GPU, the data block size can be set to a multiple of (thread block size × vector width), such as 256 × 4 = 1024 elements / block.

[0096] Achieving load balancing, memory access optimization, and maximum parallelism through scientific block partitioning strategies.

[0097] The size of each data block is dynamically determined based on the single-processing capability of the parallel computing unit, so that the block parameters match the hardware characteristics and ensure that each computing unit receives a balanced computing load. The spatial locality of data access is improved through hardware-adapted block strategy, thereby effectively improving cache utilization efficiency. Furthermore, the precise matching of block size and hardware parallelism realizes the synergistic optimization of instruction-level parallelism and data-level parallelism, giving full play to the performance potential of the parallel computing architecture.

[0098] In one optional embodiment of this application, the input dataset is divided into multiple data blocks according to the size of each data block, including: dividing the input dataset into multiple data blocks according to the target data block size; if the total amount of data n in the input dataset cannot be divided evenly by the target data block size, then n is aligned by filling in invalid data values; wherein, the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

[0099] The target data block size is a predetermined ideal block size that matches the hardware characteristics, typically an integer multiple of the processing granularity of the parallel computing unit. It serves as the basic unit for data partitioning, ensuring that each data block can be efficiently processed by the computing unit.

[0100] When the size of the input dataset is not divisible by the size of the target data block, the resulting remainder needs special handling to meet the regularity requirements of parallel computing. Ensuring all data blocks have a uniform size simplifies parallel processing logic and memory access patterns.

[0101] For example: n=1000000, block size=1024, there are 1000000÷1024=977 whole blocks, and the remainder 1000000-977×1024=1000448-1000000=448 elements need to be processed.

[0102] The key characteristic of these special padding values ​​used to maintain data alignment is that they are automatically identified and excluded in extreme value comparisons, without affecting the correctness of the actual top-k results. For example, negative infinity (-inf) is used to fill in the maximum value, while positive infinity (+inf) is used to fill in the minimum value.

[0103] By leveraging the mathematical properties of extreme value comparisons, invalid values ​​are naturally excluded from the candidate results during the sorting process. A specific number of invalid values ​​are added to the end of the data, ensuring the total data volume is an integer multiple of the block size, while guaranteeing that these padding values ​​do not affect the calculation results. Each level of filtering ensures that invalid values ​​are correctly identified and excluded, guaranteeing the purity of the final result.

[0104] When the total amount of data n in the input dataset cannot be divided by the size of the target data block, n is aligned by filling in invalid data values. The invalid data values ​​are configured to be automatically filtered out during the extreme value comparison process, thereby ensuring the regularity of the data block division, providing a balanced load basis for the computing unit, and thus supporting the efficient operation of the parallel computing architecture.

[0105] It should be noted that the method for determining k target values ​​in a parallel computing environment provided in this application embodiment can be executed by a device for determining k target values ​​in a parallel computing environment, or by a control module within that device for executing the method for determining k target values ​​in a parallel computing environment. This application embodiment uses the execution of the method for determining k target values ​​in a parallel computing environment by a device for determining k target values ​​in a parallel computing environment as an example to illustrate the method for determining k target values ​​in a parallel computing environment provided in this application embodiment.

[0106] Reference Figure 4 This illustration shows a structural block diagram of an embodiment of a device for determining k target values ​​in a parallel computing environment, provided in another embodiment of this application. Specifically, it may include: The partitioning module 201 is used to divide the input dataset into multiple data blocks; The first filtering module 202 is used to filter out the k candidate data blocks based on the local extrema of each data block obtained by parallel computing. The second filtering module 203 is used to obtain data rows in the candidate data blocks according to the block index of the k candidate data blocks, and filter out the k candidate data rows based on the row local extrema of each obtained data row obtained by parallel computing. The determining module 204 is used to obtain data in the candidate data rows according to the row index of the k candidate data rows, and determine the k target values ​​based on the obtained data.

[0107] Optionally, the second filtering module includes: The first instruction generation submodule is used to generate a first batch retrieval instruction based on the k block indices; The first instruction execution submodule is used to execute the first batch acquisition instruction to acquire data rows from the k candidate data blocks in a parallel manner.

[0108] Optionally, the device further includes: The row index calculation module is used to calculate the row index representing the global position of the candidate data row in the input dataset based on the block index of the candidate data block and the position number of the data row within it, before obtaining the data in the candidate data row according to the row index of the k candidate data rows.

[0109] Optionally, the determining module includes: The second instruction generation submodule is used to generate a second batch retrieval instruction based on the k row indices; The second instruction execution submodule is used to execute the second batch acquisition instruction to acquire data from the k candidate data rows in a parallel manner.

[0110] Optionally, the device further includes: The index calculation module is used to calculate the target value index, which represents the global position of the target value in the input dataset, based on the row index of the candidate data row and the position number of the data column inside it, after the k target values ​​are determined based on the acquired data. The index output module is used to output the k target values ​​and their corresponding target value indices.

[0111] Optionally, the partitioning module includes: Determine the submodule, which is used to determine the size of each data block based on the single data processing capability of the parallel computing unit; The partitioning submodule is used to divide the input dataset into multiple data blocks according to the size of each data block.

[0112] Optionally, the sub-module division includes: A partitioning unit is used to divide the input dataset into multiple data blocks according to the target data block size; A padding unit is used to align n by padding with invalid data values ​​if the total amount of data n in the input dataset cannot be divided evenly by the size of the target data block; wherein the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

[0113] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0114] Figure 5 This is a structural block diagram illustrating an electronic device 700 for determining k target values ​​according to an exemplary embodiment. For example, the electronic device 700 may be a computer.

[0115] Reference Figure 5 The electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power supply component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.

[0116] Processing component 702 typically controls the overall operation of electronic device 700, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 702 may include one or more modules to facilitate interaction between processing component 702 and other components. For example, processing component 702 may include a multimedia module to facilitate interaction between multimedia component 708 and processing component 702.

[0117] Memory 704 is configured to store various types of data to support the operation of device 700. Examples of this data include instruction messages, pictures, videos, etc., for any application or method operating on electronic device 700. Memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0118] Power supply component 706 provides power to various components of electronic device 700. Power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 700.

[0119] Multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation.

[0120] Audio component 710 is configured to output and / or input audio signals. For example, audio component 710 includes a microphone (MIC) configured to receive external audio signals when electronic device 700 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 704 or transmitted via communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.

[0121] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0122] Sensor assembly 714 includes one or more sensors for providing state assessments of various aspects of electronic device 700. For example, sensor assembly 714 may detect the on / off state of device 700, the relative positioning of components such as the display and keypad of electronic device 700, changes in position of electronic device 700 or a component of electronic device 700, the presence or absence of user contact with electronic device 700, orientation or acceleration / deceleration of electronic device 700, and temperature changes of electronic device 700. Sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 714 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0123] Communication component 716 is configured to facilitate wired or wireless communication between electronic device 700 and other devices. Electronic device 700 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 716 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 716 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0124] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.

[0125] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, which can be executed by a processor 720 of an electronic device 700 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0126] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a terminal's processor, enables the terminal to perform a method for determining k target values ​​in a parallel computing environment, the method comprising: Divide the input dataset into multiple data blocks; Based on the local extrema of each data block obtained by parallel computing, the k candidate data blocks are selected. Based on the block index of the k candidate data blocks, the data rows in the candidate data blocks are obtained, and the k candidate data rows are selected based on the row local extrema of each obtained data row obtained by parallel computing. Based on the row index of the k candidate data rows, the data in the candidate data rows is obtained, and the k target values ​​are determined based on the obtained data.

[0127] Optionally, obtaining the data rows in the candidate data blocks based on the block indices of the k candidate data blocks includes: Based on the k block indices, generate the first batch retrieval instructions; Execute the first batch acquisition instruction to acquire data rows from the k candidate data blocks in parallel.

[0128] Optionally, before retrieving the data from the candidate data rows based on the row indices of the k candidate data rows, the method further includes: Based on the block index of the candidate data block and the position number of the data row within it, calculate the row index that represents the global position of the candidate data row in the input dataset.

[0129] Optionally, obtaining the data in the candidate data rows based on the row indices of the k candidate data rows includes: Based on the k row indices, generate a second batch retrieval instruction; The second batch acquisition instruction is executed to acquire data from the k candidate data rows in parallel.

[0130] Optionally, after determining the k target values ​​based on the acquired data, the method further includes: Based on the row index of the candidate data row and the position number of the data column within it, calculate the target value index, which represents the global position of the target value in the input dataset; Output the k target values ​​and their corresponding target value indices.

[0131] Optionally, dividing the input dataset into multiple data blocks includes: The size of each data block is determined based on the single data processing capability of the parallel computing unit. The input dataset is divided into multiple data blocks based on the size of each data block.

[0132] Optionally, dividing the input dataset into multiple data blocks according to the size of each data block includes: The input dataset is divided into multiple data blocks according to the target data block size; If the total amount of data n in the input dataset cannot be divided evenly by the size of the target data block, then n is aligned by filling in invalid data values; wherein, the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

[0133] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts between the various embodiments, please refer to each other.

[0134] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0135] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0136] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0137] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0138] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments, as well as all changes and modifications falling within the scope of the embodiments of the present application.

[0139] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0140] The foregoing has provided a detailed description of a method for determining k target values ​​in a parallel computing environment, a device for determining k target values ​​in a parallel computing environment, an electronic device, and a readable storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for determining k target values ​​in a parallel computing environment, characterized in that, The method includes: Divide the input dataset into multiple data blocks; Based on the local extrema of each data block obtained by parallel computing, the k candidate data blocks are selected. Based on the block index of the k candidate data blocks, the data rows in the candidate data blocks are obtained, and the k candidate data rows are selected based on the row local extrema of each obtained data row obtained by parallel computing. Based on the row index of the k candidate data rows, the data in the candidate data rows is obtained, and the k target values ​​are determined based on the obtained data.

2. The method according to claim 1, characterized in that, The step of obtaining the data rows in the candidate data blocks based on the block indices of the k candidate data blocks includes: Based on the k block indices, generate the first batch retrieval instructions; Execute the first batch acquisition instruction to acquire data rows from the k candidate data blocks in parallel.

3. The method according to claim 1, characterized in that, Before retrieving the data from the candidate data rows based on their row indices, the method further includes: Based on the block index of the candidate data block and the position number of the data row within it, calculate the row index that represents the global position of the candidate data row in the input dataset.

4. The method according to claim 3, characterized in that, The step of obtaining data from the candidate data rows based on the row indices of the k candidate data rows includes: Based on the k row indices, generate a second batch retrieval instruction; The second batch acquisition instruction is executed to acquire data from the k candidate data rows in parallel.

5. The method according to claim 3, characterized in that, After determining the k target values ​​based on the acquired data, the method further includes: Based on the row index of the candidate data row and the position number of the data column within it, calculate the target value index, which represents the global position of the target value in the input dataset; Output the k target values ​​and their corresponding target value indices.

6. The method according to claim 1, characterized in that, The process of dividing the input dataset into multiple data blocks includes: The size of each data block is determined based on the single data processing capability of the parallel computing unit. The input dataset is divided into multiple data blocks based on the size of each data block.

7. The method according to claim 6, characterized in that, The step of dividing the input dataset into multiple data blocks according to the size of each data block includes: The input dataset is divided into multiple data blocks according to the target data block size; If the total amount of data n in the input dataset cannot be divided evenly by the size of the target data block, then n is aligned by filling in invalid data values; wherein, the invalid data values ​​are configured to be automatically filtered out in extreme value comparisons.

8. A device for determining k target values ​​in a parallel computing environment, characterized in that, The device includes: The partitioning module is used to divide the input dataset into multiple data blocks; The first filtering module is used to filter out the k candidate data blocks based on the local extrema of each data block obtained by parallel computing. The second filtering module is used to obtain data rows in the candidate data blocks according to the block index of the k candidate data blocks, and filter out the k candidate data rows based on the row local extrema of each obtained data row obtained by parallel computing. The determination module is used to obtain data in the candidate data rows according to the row index of the k candidate data rows, and determine the k target values ​​based on the obtained data.

9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method for determining k target values ​​for a parallel computing environment as described in any one of claims 1-10.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method for determining k target values ​​for a parallel computing environment as described in any one of claims 1-10.