Movatterモバイル変換


[0]ホーム

URL:


WO2022253287A1 - Method for generating random number, and related product thereof - Google Patents

Method for generating random number, and related product thereof
Download PDF

Info

Publication number
WO2022253287A1
WO2022253287A1PCT/CN2022/096725CN2022096725WWO2022253287A1WO 2022253287 A1WO2022253287 A1WO 2022253287A1CN 2022096725 WCN2022096725 WCN 2022096725WWO 2022253287 A1WO2022253287 A1WO 2022253287A1
Authority
WO
WIPO (PCT)
Prior art keywords
state
space
update
seed
random numbers
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2022/096725
Other languages
French (fr)
Chinese (zh)
Inventor
陈伟伦
马泽昊
于涌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cambricon Xian Semiconductor Co Ltd
Original Assignee
Cambricon Xian Semiconductor Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cambricon Xian Semiconductor Co LtdfiledCriticalCambricon Xian Semiconductor Co Ltd
Publication of WO2022253287A1publicationCriticalpatent/WO2022253287A1/en
Anticipated expirationlegal-statusCritical
Ceasedlegal-statusCriticalCurrent

Links

Images

Classifications

Definitions

Landscapes

Abstract

Disclosed are an apparatus for generating a random number, an integrated circuit chip, a board, an electronic device, and a method for generating a random number. The apparatus can be comprised in a combined processing apparatus, and the combined processing apparatus can further comprise an interface apparatus and another processing apparatus. Computation apparatuses interact with the another processing apparatus to jointly complete a computation operation specified by a user. The combined processing apparatus can further comprise a storage apparatus, and the storage apparatus is separately connected to a device and the another processing apparatus and is used for storing data of the device and the another processing apparatus. According to the solution of the present disclosure, the efficiency of generation of the random number can be improved, and the flow performance of hardware execution is improved.

Description

Translated fromChinese
用于生成随机数的方法及其相关产品Method for generating random numbers and related products

相关申请的交叉引用Cross References to Related Applications

本公开要求于2021年6月4日申请的、申请号为202110622813.4、发明名称为“用于生成随机数的方法及其相关产品”的中国专利申请的优先权。This disclosure claims the priority of the Chinese patent application with the application number 202110622813.4 and the title of the invention "method for generating random numbers and related products" filed on June 4, 2021.

技术领域technical field

本披露一般地涉及随机数领域。更具体地,本披露涉及一种用于生成随机数的装置、集成电路芯片、板卡、电子设备和方法。The present disclosure relates generally to the field of random numbers. More specifically, the present disclosure relates to a device for generating random numbers, an integrated circuit chip, a board, electronic equipment and a method.

背景技术Background technique

在类似于统计应用、试验测试等多个场景中,随机数有着广泛的应用基础。随着统计或测试的数据量增加,对生成随机数的数据量大小和生成效率也提出更高的要求。通常,随机数的生成算法中涉及大量的数据迭代运算,这就要求生成随机数的硬件架构能够适应这样的运算要求。然而,在现有的随机数生成方式中,硬件架构并不支持流水操作并且由此导致随机数的生成效率相对较低。Random numbers have a broad application base in many scenarios such as statistical applications and experimental tests. As the amount of statistical or testing data increases, higher requirements are placed on the size and efficiency of generating random numbers. Usually, a large number of data iteration operations are involved in the random number generation algorithm, which requires the hardware architecture for generating random numbers to be able to adapt to such operation requirements. However, in the existing random number generation methods, the hardware architecture does not support pipelining and thus the efficiency of random number generation is relatively low.

发明内容Contents of the invention

为了至少解决上述现有技术中存在的问题,本披露提供一种以流水方式生成随机数的方案。本披露的方案可以在包括增强硬件的处理性能、减小功耗、提高计算操作的执行效率和避免计算开销等多个方面获得技术优势。In order to at least solve the above-mentioned problems in the prior art, the present disclosure provides a solution for generating random numbers in a pipelined manner. The solution disclosed in the present disclosure can obtain technical advantages in multiple aspects including enhancing hardware processing performance, reducing power consumption, improving execution efficiency of computing operations, and avoiding computing overhead.

在第一方面中,本披露提供一种用于生成随机数的装置,包括:指令译码单元,其配置成接收随机数指令并且对所述随机数指令进行译码;运算单元,其配置成根据所述译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量;以及存储器,其配置成根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受来自运算单元对所述状态空间的状态向量更新,其中所述状态空间的大小设置成:在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者在多个种子下,支持以流水方式执行各个种子的随机数生成操作。In a first aspect, the present disclosure provides a device for generating a random number, including: an instruction decoding unit configured to receive a random number instruction and decode the random number instruction; an operation unit configured to Perform a random number generation operation based on a single seed or a plurality of seeds according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes a generation operation and an update performed in a pipelined manner operations, wherein the generate operation is used to generate a random number and the update operation is used to update a state vector; and a memory configured to set up a state space according to the decoded random number instruction, wherein the state space configures store the state vector used to generate the random number and receive state vector updates from the computing unit to the state space, wherein the state space is sized to support pipelined execution of the generation under a single seed Operation and update operation; or under multiple seeds, it supports the random number generation operation of each seed in a pipelined manner.

在第二方面中,本披露提供一种集成电路芯片,其包括如上所述并且将在下面多个实施例中描述的用于生成随机数的装置。In a second aspect, the present disclosure provides an integrated circuit chip comprising the apparatus for generating random numbers as described above and in the following embodiments.

在第三方面中,本披露提供一种板卡,其包括如上所述并且将在下面多个实施例中描述的集成电路芯片。In a third aspect, the present disclosure provides a board comprising the integrated circuit chip as described above and will be described in several embodiments below.

在第四方面中,本披露提供一种电子设备,其包括如上所述并且将在下面多个实施例中描述的集成电路芯片。In a fourth aspect, the present disclosure provides an electronic device comprising an integrated circuit chip as described above and as will be described in a number of embodiments below.

在第五方面中,本披露提供一种用于生成随机数的方法,包括:接收随机数指令并且对所述随机数指令进行译码;根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受对所述状态空间的状态向量更新;以及根据所述译码后的随机数指令来执行基于单个种子或多个种 子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量,其中所述状态空间的大小设置成:在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者在多个种子下,支持以流水方式执行各个种子的随机数生成操作。In a fifth aspect, the present disclosure provides a method for generating a random number, including: receiving a random number instruction and decoding the random number instruction; setting a state space according to the decoded random number instruction , wherein the state space is configured to store state vectors used to generate the random numbers and to accept state vector updates to the state space; and to execute based on a single seed or multiple A random number generation operation for seeds, wherein for each of the seeds, the random number generation operation includes a generation operation and an update operation performed in a pipelined manner, wherein the generation operation is used to generate a random number and the update operation is used For updating the state vector, wherein the size of the state space is set to: under a single seed, support the generation operation and the update operation in a pipeline; or under multiple seeds, support the random number of each seed in a pipeline Build operation.

通过利用本披露的用于生成随机数的装置、集成电路芯片、板卡、电子设备和方法,可以实现硬件以流水的方式来执行随机数的生成操作。由此,本披露的方案可以借助于流水操作来高效地生成随机数,从而提升硬件的整体性能并减小计算开销。进一步,本披露的方案不仅支持单个种子下的随机数生成操作,还支持多个种子下的随机数生成操作,从而随机数的生成方式更为灵活并且效率更高。特别地,在多种子的随机数生成操作中,硬件的流水操作性能将得到进一步提升。By using the device, integrated circuit chip, board, electronic device and method for generating random numbers disclosed in the present disclosure, hardware can be implemented to perform random number generation operations in a pipelined manner. Therefore, the solution of the present disclosure can efficiently generate random numbers by means of pipeline operation, thereby improving the overall performance of hardware and reducing calculation overhead. Furthermore, the solution disclosed in the present disclosure not only supports random number generation operations under a single seed, but also supports random number generation operations under multiple seeds, so that the random number generation method is more flexible and more efficient. In particular, in multi-seed random number generation operations, the hardware pipeline performance will be further improved.

附图说明Description of drawings

通过参考附图阅读下文的详细描述,本公开示例性实施方式的上述以及其他目的、特征和优点将变得易于理解。在附图中,以示例性而非限制性的方式示出了本公开的若干实施方式,并且相同或对应的标号表示相同或对应的部分其中:The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of the present disclosure are shown by way of illustration and not limitation, and the same or corresponding reference numerals indicate the same or corresponding parts wherein:

图1是示出根据本披露实施例的用于生成随机数的装置的框图;FIG. 1 is a block diagram illustrating an apparatus for generating random numbers according to an embodiment of the present disclosure;

图2是示出根据本披露一个实施例的用于生成随机数的初始化过程的示意图;FIG. 2 is a schematic diagram illustrating an initialization process for generating random numbers according to an embodiment of the present disclosure;

图3是示出根据本披露又一个实施例的用于生成随机数的初始化过程的示意图;FIG. 3 is a schematic diagram illustrating an initialization process for generating random numbers according to yet another embodiment of the present disclosure;

图4是示出根据本披露一个实施例的用于生成随机数的状态空间变化示意图;FIG. 4 is a schematic diagram showing state space changes for generating random numbers according to an embodiment of the present disclosure;

图5a是示出根据本披露又一个实施例的用于生成随机数的部分状态空间变化的示意图;Fig. 5a is a schematic diagram illustrating partial state space changes for generating random numbers according to yet another embodiment of the present disclosure;

图5b是示出根据本披露又一个实施例的用于生成随机数的另一部分状态空间变化的示意图;Fig. 5b is a schematic diagram illustrating another part of the state space variation for generating random numbers according to yet another embodiment of the present disclosure;

图6是示出根据本披露实施例的用于生成随机数的方法的流程图;FIG. 6 is a flowchart illustrating a method for generating a random number according to an embodiment of the present disclosure;

图7是示出根据本披露实施例的单种子模式下生成随机数的方法的流程图;FIG. 7 is a flowchart showing a method for generating random numbers in a single seed mode according to an embodiment of the present disclosure;

图8是示出根据本披露实施例的双种子模式下生成随机数的方法的流程图;FIG. 8 is a flow chart illustrating a method for generating random numbers in a dual-seed mode according to an embodiment of the present disclosure;

图9是示出根据本披露实施例的一种组合处理装置的结构图;以及FIG. 9 is a structural diagram showing a combined processing device according to an embodiment of the present disclosure; and

图10是示出根据本披露实施例的一种板卡的结构示意图。Fig. 10 is a schematic structural diagram showing a board according to an embodiment of the present disclosure.

具体实施方式Detailed ways

本披露提供一种以并行流水或乒乓方式来高效生成随机数的方案。为此,在一个实施例中,本披露提出对存储用于生成随机数的状态向量的状态空间进行有效设置,从而使得该状态空间满足流水操作时的硬件要求。特别地,在利用单个种子和多个种子来生成随机数的场景中,本披露提出将状态空间进行扩展,以便使其支持在前述的两种场景中,以流水方式来执行生成随机数过程中的生成操作和更新操作。结合对状态空间的改进,本披露的方案还提出利用解析后得到的多条微指令的随机数指令来执行前述的生成操作和更新操作。借助于本披露的硬件设置和随机数指令,可以高效地生成随机数,从而提升计算系统的整体性能并且减小了生成随机数的开销。The present disclosure provides a scheme for efficiently generating random numbers in a parallel pipeline or ping-pong manner. To this end, in one embodiment, the present disclosure proposes to effectively set the state space for storing state vectors used to generate random numbers, so that the state space meets hardware requirements for pipeline operations. In particular, in the scenario where a single seed or multiple seeds are used to generate random numbers, this disclosure proposes to expand the state space so that it supports the process of generating random numbers in a pipelined manner in the aforementioned two scenarios The build and update operations for . Combined with the improvement of the state space, the solution disclosed in the present disclosure also proposes to use the random number instructions of multiple microinstructions obtained after analysis to perform the aforementioned generation operation and update operation. With the help of the hardware configuration and random number instructions disclosed in the present disclosure, random numbers can be efficiently generated, thereby improving the overall performance of the computing system and reducing the overhead of generating random numbers.

下面将结合附图对本披露实施例中的技术方案进行清楚和完整地描述。可以理解的是下文所描述的实施例仅仅是本公开的一部分实施例,而并不是全部的实施例。基 于本披露中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本披露旨在保护的范围。The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. It should be understood that the embodiments described below are only some of the embodiments of the present disclosure, but not all of the embodiments. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without making creative efforts belong to the intended protection scope of this disclosure.

图1是示出根据本披露实施例的用于生成随机数的装置100的框图。如图1所示,本披露的装置100包括指令译码单元101、运算单元102和存储器103,三者相互交互和配合,从而实现以流水方式来生成随机数。在一个实施场景,该指令译码单元可以配置成接收随机数指令并且对该随机数指令进行译码。在一个实施例中,本披露的随机数指令根据实现场景的不同可以包括以下中的一项或多项:生成随机数的数目、状态空间的大小和地址、用于生成随机数的一个或多个种子信息、用于拼接随机数的拼接参数和输出随机数的地址等。在一个实施例中,随机数指令可以是单个的指令,并且在经指令译码单元解析后得到多个或多条微指令。在另一个实施例中,种子信息可以包括具体的种子(例如32位长的初始数值)或者指示种子是否来自于特殊功能寄存器的信息。关于前述的用于拼接随机数的拼接参数,在应用两个种子的情形中,其可以包括存储与第一种子关联的随机数的首地址以及地址偏移(也即利用第一种子生成所有随机数后的存储地址跨度)。由此,运算单元可以确定用于存储与第二种子关联的随机数的首地址,也即前述第一种子的首地址加上其地址偏移。FIG. 1 is a block diagram illustrating anapparatus 100 for generating random numbers according to an embodiment of the present disclosure. As shown in FIG. 1 , thedevice 100 of the present disclosure includes aninstruction decoding unit 101 , acomputing unit 102 and amemory 103 , and the three interact and cooperate with each other, so as to generate random numbers in a pipelined manner. In an implementation scenario, the instruction decoding unit may be configured to receive a random number instruction and decode the random number instruction. In one embodiment, the random number instructions disclosed in the present disclosure may include one or more of the following according to different implementation scenarios: the number of generated random numbers, the size and address of the state space, one or more Seed information, splicing parameters for splicing random numbers, address of outputting random numbers, etc. In one embodiment, the random number instruction may be a single instruction, and after being parsed by the instruction decoding unit, multiple or multiple microinstructions are obtained. In another embodiment, the seed information may include a specific seed (for example, a 32-bit initial value) or information indicating whether the seed comes from a special function register. Regarding the aforementioned splicing parameters for splicing random numbers, in the case of applying two seeds, it may include storing the first address and address offset of the random numbers associated with the first seed (that is, using the first seed to generate all random numbers) number of storage address spans). Thus, the computing unit can determine the first address for storing the random number associated with the second seed, that is, the first address of the aforementioned first seed plus its address offset.

在一个实施场景中,运算单元可以配置成根据译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作。具体地,针对于每个种子,本披露的随机数生成操作可以包括以流水方式执行的生成操作和更新操作。这里,生成操作可以用于生成随机数并且更新操作可以用于更新状态向量。根据不同的应用场景,本披露的运算单元可以具有不同的实现方式。当应用于人工智能领域的硬件架构时,本披露的运算单元可以实现为人工智能处理器或处理器中的计算核。In an implementation scenario, the operation unit may be configured to perform a random number generation operation based on a single seed or multiple seeds according to the decoded random number instruction. Specifically, for each seed, the random number generation operation of the present disclosure may include a generation operation and an update operation executed in a pipelined manner. Here, the generate operation can be used to generate random numbers and the update operation can be used to update the state vector. According to different application scenarios, the computing unit of the present disclosure may have different implementation manners. When applied to a hardware architecture in the field of artificial intelligence, the computing unit of the present disclosure can be implemented as an artificial intelligence processor or a computing core in a processor.

在一个实施场景中,存储器可以配置成根据译码后的随机数指令来设置状态空间。在本披露的上下文中,状态空间可以配置成存储用于生成随机数的状态向量并且接受来自运算单元对状态空间的状态向量更新。进一步,本披露的状态空间的大小可以设置成使得在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者在多个种子下,支持以流水方式执行各个种子的随机数生成操作。在一个实施方式中,本披露的状态空间的大小可以通过软件来配置。通过软件来进行配置状态空间大小的配置,可以使得状态空间大小的设置更为灵活和方便,从而也使得状态空间可以更好地支持本披露随机数生成方案在单个种子和多个种子模式下的流水操作。In one implementation scenario, the memory may be configured to set up the state space according to the decoded random number instruction. In the context of the present disclosure, the state space may be configured to store state vectors used to generate random numbers and to accept state vector updates to the state space from the arithmetic unit. Further, the size of the state space in the present disclosure can be set such that under a single seed, the generation operation and the update operation are supported to be executed in a pipeline; or under multiple seeds, the random number generation operation of each seed is supported in a pipeline . In one embodiment, the size of the state space of the present disclosure can be configured by software. Configuring the size of the state space through software can make the setting of the size of the state space more flexible and convenient, so that the state space can better support the random number generation scheme of the present disclosure in single seed and multiple seed modes Flow operation.

在生成随机数的过程中,运算单元可以从状态空间(其可以视为一个循环利用的存储空间)读取至少一个状态向量来生成随机数,并且可以通过基于所述至少一个状态向量的更新操作来生成更新后的状态向量。进一步,可以利用该更新后的状态向量来对状态空间进行更新。下面将结合前文提到的随机数指令来对本披露的随机数生成操作进行详细的描述。In the process of generating random numbers, the computing unit can read at least one state vector from the state space (which can be regarded as a recycled storage space) to generate random numbers, and can perform an update operation based on the at least one state vector to generate the updated state vector. Further, the updated state vector can be used to update the state space. The random number generation operation of the present disclosure will be described in detail below in conjunction with the aforementioned random number instruction.

如前所述,本披露的随机数指令可以实现为单个指令并且在经指令译码单元进行解析后,可以得到用于执行流水操作的多条微指令。根据该多条微指令,运算单元可以配置成以循环移位的方式沿状态空间来执行生成随机数的生成操作和更新状态空间的更新操作。具体地,根据微指令,运算单元可以利用状态空间中划分的多段空间区段中的一段空间区段上存储的状态向量来执行随机数的生成操作,以生成预定部分数目的随机数。接着,可以利用前述空间区段上存储的状态向量来生成新的状态向量, 并且将该新的状态向量存储于状态空间的多段空间区段中的另一段空间区段上。为了实现流水操作并且减小数据之间的地址依赖性,本披露提出将前述两段空间区段布置的足够远,并且在状态向量更新后立即利用与前述两个空间区段的不同区段来执行生成随机数操作,从而最小化运算单元的等待时间并由此提升运算单元在生成随机数方面的运算效率。As mentioned above, the random number instruction of the present disclosure can be realized as a single instruction and after being analyzed by the instruction decoding unit, multiple microinstructions for executing pipeline operation can be obtained. According to the plurality of microinstructions, the arithmetic unit can be configured to perform a generating operation for generating random numbers and an updating operation for updating the state space along the state space in a circular shifting manner. Specifically, according to the microinstructions, the operation unit can use the state vector stored in one of the multiple space segments divided in the state space to perform a random number generation operation, so as to generate a predetermined partial number of random numbers. Then, a new state vector can be generated by using the state vector stored on the aforementioned space segment, and the new state vector can be stored in another segment of the multi-segment space segments of the state space. In order to realize pipelining and reduce the address dependence between data, this disclosure proposes to arrange the aforementioned two space segments far enough apart, and use a different segment from the aforementioned two space segments immediately after the state vector is updated. The operation of generating random numbers is performed, thereby minimizing the waiting time of the operation unit and thereby improving the operation efficiency of the operation unit in generating random numbers.

在一个实施方式中,用于随机数生成的状态空间可以实施为一个循环利用的存储空间。由此,上述的多个空间区段根据要执行的生成操作和更新操作而可变地操作于读取空间区段或写入空间区段。换句话说,随着生成操作和更新操作的迭代循环执行,先前用于读取的空间区段在后续的操作中转换成写入区段,以用于新的状态向量的写入,即执行本披露的状态空间的更新。进一步,为了实现随机数的生成操作和状态向量的更新操作以流水方式执行,可以在状态空间中将前述的读取空间区段和写入空间区段设置成具有预定的地址间隔,以最小化后续生成操作和更新操作中状态向量之间的地址依赖性。In one embodiment, the state space used for random number generation can be implemented as a recycled storage space. Thus, the above-mentioned plurality of space segments can be variably operated on the read space segment or the write space segment according to the generation operation and the update operation to be performed. In other words, as the iterative cycle of the generate operation and the update operation is performed, the space segment previously used for reading is converted into a write segment in the subsequent operation for the writing of the new state vector, that is, the execution An update of the state space of the present disclosure. Further, in order to implement the random number generation operation and the update operation of the state vector in a pipelined manner, the aforementioned read space segment and write space segment can be set to have a predetermined address interval in the state space to minimize Address dependencies between state vectors in subsequent generate operations and update operations.

在一个实施场景中,为了实现随机数指令的连续调用和执行,本披露的指令译码单元可以配置成向存储器中的状态空间输出状态指针,该状态指针可以指示用于生成操作的第一状态向量在所述状态空间中的位置(如稍后结合附图描述的Y[i+N]在状态空间中的坐标)和用于更新操作的第一更新状态向量在状态空间中的位置(如稍后结合附图描述的X[i]在状态空间中的坐标)。基于该状态指针,运算单元可以知晓前次执行随机数指令后第一状态向量和第一更新状态向量在状态空间中的位置,从而可以在该位置起执行下一随机数指令的生成操作和更新操作。In an implementation scenario, in order to realize continuous calling and execution of random number instructions, the instruction decoding unit of the present disclosure may be configured to output a state pointer to the state space in the memory, and the state pointer may indicate the first state used to generate the operation The position of the vector in the state space (such as the coordinates of Y[i+N] in the state space described later in conjunction with the accompanying drawings) and the position of the first update state vector used for the update operation in the state space (such as The coordinates of X[i] in the state space described later in conjunction with the accompanying drawings). Based on the state pointer, the arithmetic unit can know the positions of the first state vector and the first updated state vector in the state space after the previous execution of the random number instruction, so that the generation operation and update of the next random number instruction can be performed from this position operate.

在一个实施场景中,本披露的状态空间可以包括N个连续分布的读取空间区段和N个连续分布的写入空间区段,并且N个读取空间区段和所述N个写入空间区段在流水操作中形成对应关系,其中N是大于或等于2的正整数。基于前述的预设条件(例如通过随机数指令来配置),在流水操作过程中,运算单元可以配置成根据预生成的随机数的数目循环执行以下的操作,其中i=1,…N:In an implementation scenario, the state space of the present disclosure may include N continuously distributed read space segments and N continuously distributed write space segments, and the N read space segments and the N write space segments The spatial segments form a corresponding relationship in the pipeline operation, where N is a positive integer greater than or equal to 2. Based on the aforementioned preset conditions (for example, configured by random number instructions), during the pipeline operation process, the arithmetic unit can be configured to perform the following operations cyclically according to the number of pre-generated random numbers, where i=1,...N:

在用于生成随机数的生成操作中,运算单元可以从第i读取空间区段中读取多个状态向量,以生成对应的第i多个随机数;以及In the generation operation for generating random numbers, the computing unit may read a plurality of state vectors from the i-th read space section to generate corresponding i-th plurality of random numbers; and

在用于更新状态空间的更新操作中,运算单元可以根据第i读取空间区段中的多个状态向量来生成用于更新状态空间的多个状态更新向量,并且将该多个状态更新向量写入所述第i写入空间区段。In the update operation for updating the state space, the operation unit may generate a plurality of state update vectors for updating the state space based on a plurality of state vectors in the i-th read space section, and the plurality of state update vectors Write the i-th write space segment.

如前所述,本披露的运算单元可以根据随机数指令来生成预定数目的随机数。当随机数指令由指令译码单元解析成多条微指令(包括一个或多个生成微指令和更新微指令)时,则运算单元可以根据不同的微指令组合来分若干次生成部分数目的随机数并且更新部分数目的状态向量,直至最终生成预期数目的随机数。具体来说,本披露的运算单元可以根据一条生成微指令来生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量。或者,运算单元可以根据一条生成微指令来生成部分数目的随机数,并且根据多条更新微指令来分别更新部分数目的状态向量。附加地,运算单元可以根据多条生成微指令来分别生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量。此处关于不同微指令的组合使用方式仅仅是示例性的和概括性的,稍后将结合附图对该组合操作方式进行更为具体的描述。As mentioned above, the arithmetic unit of the present disclosure can generate a predetermined number of random numbers according to a random number instruction. When the random number instruction is analyzed by the instruction decoding unit into multiple microinstructions (including one or more generated microinstructions and update microinstructions), the arithmetic unit can generate a partial number of random numbers several times according to different microinstruction combinations. number and update a partial number of state vectors until the expected number of random numbers is finally generated. Specifically, the arithmetic unit of the present disclosure can generate a partial number of random numbers according to a generation microinstruction, and update a partial number of state vectors according to an update microinstruction. Alternatively, the arithmetic unit may generate a partial number of random numbers according to one generating microinstruction, and update a partial number of state vectors according to multiple updating microinstructions. Additionally, the arithmetic unit can respectively generate a partial number of random numbers according to multiple generating microinstructions, and update a partial number of state vectors according to one updating microinstruction. The combined use of different microinstructions here is only exemplary and general, and the combined operation will be described in more detail later with reference to the accompanying drawings.

为了最大程度地减小微指令的读操作(如从状态空间读取状态向量以生成随机数)和写操作(如向状态空间写入新的状态向量以更新状态空间)在地址上的交叠,本披露提出在每条微指令中包括指示针对状态空间的读取操作或写入操作的地址范围项,并且对于地址范围项存在地址交叠的两条连续微指令,运算单元将被配置成仅在执行完其中一条微指令的读取操作或写入操作后,才执行下一条微指令的读取操作或写入操作。In order to minimize the overlap of read operations (such as reading a state vector from the state space to generate random numbers) and write operations (such as writing a new state vector to the state space to update the state space) of microinstructions on the address overlap , the present disclosure proposes to include an address range item indicating a read operation or a write operation for the state space in each microinstruction, and for two consecutive microinstructions with overlapping addresses in the address range item, the arithmetic unit will be configured as Only after the read or write operation of one microinstruction is executed, the read or write operation of the next microinstruction is executed.

在一个实施例中,在对状态空间的初始化过程中,本披露提出将状态空间划分成大小相同的第一状态子空间和第二状态子空间。在该情形中,运算单元可以配置成利用存储于第一状态子空间中的状态向量来执行针对第二状态子空间的更新操作,以生成用于第二状态子空间的所有状态向量。当以前文的N来表示状态空间中的第一状态子空间的状态向量数目(此时N表示第一状态子空间中的N个连续区段,每个区段包括一个状态向量),则通过利用第一状态子空间中的0~N-1总计N个状态向量来仅执行状态空间的更新操作以生成新的N个状态向量,从而可以得到包括0~2N-1总计N个状态向量的状态空间。在生成第二状态子空间的所有状态向量中,运算单元还可以配置成顺序地执行多条微指令,以生成用于更新第二状态子空间的所有状态向量(即前例中从N~2N-1共计N个状态向量),其中每条微指令的执行生成对应数目的状态向量。In one embodiment, during the initialization of the state space, the present disclosure proposes to divide the state space into a first state subspace and a second state subspace of the same size. In this case, the arithmetic unit may be configured to perform an update operation for the second state subspace using state vectors stored in the first state subspace to generate all state vectors for the second state subspace. When the previous N is used to represent the number of state vectors in the first state subspace in the state space (N represents N consecutive sections in the first state subspace at this time, each section includes a state vector), then by A total of N state vectors from 0 to N-1 in the first state subspace are used to perform only the update operation of the state space to generate new N state vectors, so that a total of N state vectors from 0 to 2N-1 can be obtained. state space. In generating all the state vectors of the second state subspace, the arithmetic unit can also be configured to execute a plurality of microinstructions sequentially to generate all state vectors for updating the second state subspace (i.e. from N to 2N- 1 A total of N state vectors), wherein the execution of each microinstruction generates a corresponding number of state vectors.

如前所述,本披露的方案提供了单种子模式和多种子模式的随机数生成方案。在单个种子下,本披露的运算单元可以配置成利用单个种子生成的状态向量来执行前述的生成操作以生成所述随机数,并且执行前述的更新操作以更新状态空间的相关状态向量。具体地,在单个种子的情形下,运算单元可以配置成根据多条微指令来连续地交替执行生成所述随机数的生成操作和用于更新状态空间的更新操作,直至生成预定数目的随机数。在一个实施场景中,每次生成操作生成部分数目的随机数并且每次更新操作更新所述状态空间中对应数目的状态向量。As mentioned above, the scheme of the present disclosure provides a random number generation scheme of a single sub-mode and multiple sub-modes. Under a single seed, the computing unit of the present disclosure may be configured to use the state vector generated by the single seed to perform the aforementioned generating operation to generate the random number, and perform the aforementioned updating operation to update the relevant state vector of the state space. Specifically, in the case of a single seed, the operation unit may be configured to continuously and alternately perform the generation operation for generating the random number and the update operation for updating the state space according to a plurality of microinstructions until a predetermined number of random numbers are generated . In one implementation scenario, each generation operation generates a partial number of random numbers and each update operation updates a corresponding number of state vectors in the state space.

替代地或附加地,在多个种子的情形下,每个种子可以具有其关联的状态空间,也即针对每个种子来设置其状态空间。在该情形下,运算单元可以配置成分别利用多个种子中的各个种子生成的状态向量来执行与各个种子关联的生成操作,以生成与各个种子关联的所述随机数,并且执行与各个种子关联的更新操作以更新与各个种子关联的状态空间的相关状态向量。当多个种子包括第一种子和第二种子时,本披露的存储器设置有与第一种子和第二种子各自关联的所述状态空间。基于此,在执行用于生成随机数的流水操作中,本披露的运算单元可以配置成根据随机数指令来循环执行如下操作,直至生成预定数目的随机数。具体来说,运算单元可以利用第一种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。接着,运算单元可以利用第二种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。通过反复迭代地执行第一种子关联的生成操作和更新操作以及第二种子关联的生成操作和更新操作,本披露的方案明显提升了生成预期数目随机数的速度和效率,实现了硬件的流水执行,从而提升了硬件的整体性能。Alternatively or additionally, in case of multiple seeds, each seed may have its associated state space, ie its state space is set for each seed. In this case, the operation unit may be configured to use the state vector generated by each of the plurality of seeds to perform the generating operation associated with each seed, so as to generate the random number associated with each seed, and perform the generation operation associated with each seed. The associated update operation to update the associated state vectors of the state space associated with each seed. When the plurality of seeds includes a first seed and a second seed, the memory of the present disclosure is provided with the state spaces associated with each of the first seed and the second seed. Based on this, in performing the pipeline operation for generating random numbers, the arithmetic unit of the present disclosure may be configured to perform the following operations cyclically according to the random number instruction until a predetermined number of random numbers are generated. Specifically, the computing unit may use the state space associated with the first seed to generate partial random numbers, and update a corresponding number of state vectors. Then, the operation unit may use the state space associated with the second seed to generate a partial random number, and update a corresponding number of state vectors. By repeatedly and iteratively executing the generation operation and update operation associated with the first seed and the generation operation and update operation associated with the second seed, the solution disclosed in this disclosure significantly improves the speed and efficiency of generating the expected number of random numbers, and realizes hardware pipeline execution , thereby improving the overall performance of the hardware.

图2是示出根据本披露一个实施例的用于生成随机数的初始化过程的示意图。为了便于理解,图中以直线表示设置于图1中存储器内的状态空间的大小,而以圆点表示状态空间中的状态向量。如前所述,状态向量用于一定数目的随机数的生成和状态 向量的更新。进一步,为了实现硬件的流水执行,本披露提出对状态空间进行扩展,例如将原有支持N个状态向量的状态空间扩展到支持2N个状态向量的状态空间。Fig. 2 is a schematic diagram illustrating an initialization process for generating random numbers according to an embodiment of the present disclosure. For ease of understanding, in the figure, the size of the state space provided in the memory in FIG. 1 is represented by a straight line, and the state vector in the state space is represented by a dot. As mentioned earlier, the state vector is used to generate a certain number of random numbers and update the state vector. Further, in order to realize the pipeline execution of hardware, the present disclosure proposes to extend the state space, for example, extending the original state space supporting N state vectors to a state space supporting 2N state vectors.

如图2中上部所示,在初始化过程中,根据译码后的随机数指令,运算单元可以利用种子来生成包含N个状态向量的状态空间。例如,可以生成N=351个(即从第0个~第350个)状态向量的状态空间。当一个状态向量占用4个字节时,则该N=351的初始状态空间占用1404个字节。在使用例如“用于图形处理器动态生成器的梅森旋转”(Mersenne Twister for Graphic Processor Dynamic Creator,“MTGPDC”)随机数生成算法时,图2中还示出用于生成更新状态空间的三个状态向量x[i]、x[i+1]和x[i+M],三者通过如下操作来生成用于更新的状态向量X[i+N]:As shown in the upper part of Fig. 2, in the initialization process, according to the decoded random number instruction, the operation unit can use the seed to generate a state space containing N state vectors. For example, a state space of N=351 (that is, from 0th to 350th) state vectors can be generated. When a state vector occupies 4 bytes, the initial state space of N=351 occupies 1404 bytes. Also shown in Figure 2 are the three methods used to generate the updated state space when using, for example, the Mersenne Twister for Graphic Processor Dynamic Creator ("MTGPDC") random number generation algorithm The state vectors x[i], x[i+1] and x[i+M], the three generate the state vector X[i+N] for updating through the following operations:

t=X[i+1]^(x[i]|mask);t=X[i+1]^(x[i]|mask);

t=t^(t<<sh1);t=t^(t<<sh1);

u=t^(X[i+M]>>sh2);u=t^(X[i+M]>>sh2);

X[i+N]=u^(R_table[u&0xF])。X[i+N]=u^(R_table[u&0xF]).

通过反复执行例如如上的操作,可以将0~N-1的状态空间扩展到如图2下部所示出的0~2N-1的状态空间,从而完成本披露的初始化过程。在一些实施方式中,0~N-1的状态空间的初始化可以由通用处理器(“CPU”)来执行,而N~2N-1的状态空间的初始化可以由智能处理器来执行。仍以上述的N=351为例,当生成351个状态向量后,可以利用四条微指令来完成将状态向量从N个扩展到2N个。具体地,以第一条微指令来更新96个状态向量;接着,以第二条微指令来更新(N-M-96)个状态向量;又接着,更新min(96,M)个状态向量,其中如果M≤96个状态,则更新M个状态向量,从而完成初始化N~2N-1个状态向量;反之,当M>96时,则存在第四条微指令,其用于更新(M-96)个状态向量,从而完成初始化N~2N-1个状态向量。By repeatedly performing the above operations, for example, the state space of 0-N-1 can be extended to the state space of 0-2N-1 as shown in the lower part of FIG. 2 , thereby completing the initialization process of the present disclosure. In some embodiments, the initialization of the state space of 0∼N-1 may be performed by a general-purpose processor ("CPU"), and the initialization of the state space of N∼2N-1 may be performed by an intelligent processor. Still taking the aforementioned N=351 as an example, after generating 351 state vectors, four microinstructions can be used to expand the state vectors from N to 2N. Specifically, 96 state vectors are updated with the first microinstruction; then, (N-M-96) state vectors are updated with the second microinstruction; and then, min(96, M) state vectors are updated, wherein If M≤96 states, then update M state vectors, thereby completing the initialization of N~2N-1 state vectors; otherwise, when M>96, then there is a fourth microinstruction, which is used for updating (M-96 ) state vectors, thus completing the initialization of N~2N-1 state vectors.

可以理解的是上述的初始化过程适用于本披露的单个种子模式或多个种子模式下的初始化过程。特别地,对于多个种子的模式,本披露的方案提出针对多个种子中的每个种子来初始化N个状态,并且接着例如按照如上所述方式将N个状态扩展到2N个状态,从而将包含N个状态向量的状态空间扩展到包含2N个状态向量的状态空间。在一个实施场景中,上述的初始化过程适用于处理或运算能力相对较小的处理器核(简称“小核”)的方案。下面结合图3来描述处理或运算能力相对较大(也即在每个时钟周期执行相对较多的运算操作)的处理器核(简称“大核”)下的初始化过程。It can be understood that the above initialization process is applicable to the initialization process in a single seed mode or multiple seed modes in the present disclosure. In particular, for a multi-seed pattern, the scheme of the present disclosure proposes to initialize N states for each of the multi-seeds, and then expand the N states to 2N states, for example as described above, so that The state space containing N state vectors is extended to a state space containing 2N state vectors. In an implementation scenario, the above initialization process is applicable to a solution of a processor core with a relatively small processing or computing capability (referred to as "small core"). The initialization process under the processor core (referred to as "big core") with relatively large processing or computing capability (that is, performing relatively many computing operations in each clock cycle) will be described below in conjunction with FIG. 3 .

图3是示出根据本披露又一个实施例的用于生成随机数的初始化过程的示意图,也即上文提到的“大核”方案的初始化过程。需要注意的是,0~N-1个状态向量的初始化过程与前文的“小核”方案类似,其例如可以由片外系统(如CPU)来生成。接着,从如图3的上部所示的具有0~N-1个状态向量的状态开始,首先利用随机数算法(如前面的“MTGPDC”)中的更新操作来生成(N-M)个状态向量,从而从N开始更新(N-M)个状态向量,如图3中部从“N”至“2N-M-1”的带箭头的线段所示出的。此后,再接着更新M个状态,如图3下部从“2N-M-1”至“2N-1”的带箭头的线段所示出的。在一个实施场景中,前述从“N”至“2N-M-1”和从“2N-M-1”至“2N-1”的状态向量的初始化可以通过两条微指令来实现,从而最终将包含N个状态向量的状态空间扩展到具有2N个状态向量的状态空间,以支持后续的生成随机数的流水操作。Fig. 3 is a schematic diagram illustrating an initialization process for generating random numbers according to yet another embodiment of the present disclosure, that is, the initialization process of the "big core" solution mentioned above. It should be noted that the initialization process of 0-N-1 state vectors is similar to the above "small core" solution, which can be generated by an off-chip system (such as a CPU), for example. Next, starting from the state with 0 ~ N-1 state vectors as shown in the upper part of Fig. 3, first use the update operation in the random number algorithm (such as the previous "MTGPDC") to generate (N-M) state vectors, Thus, (N-M) state vectors are updated starting from N, as shown by the arrowed line segment from "N" to "2N-M-1" in the middle of FIG. 3 . Thereafter, M states are updated, as shown by the arrowed line segment from "2N-M-1" to "2N-1" in the lower part of Fig. 3 . In an implementation scenario, the initialization of the aforementioned state vectors from "N" to "2N-M-1" and from "2N-M-1" to "2N-1" can be realized by two microinstructions, so that finally Extend the state space containing N state vectors to a state space with 2N state vectors to support subsequent pipeline operations for generating random numbers.

图4是示出根据本披露一个实施例的用于生成随机数的状态空间变化示意图。为了便于理解本披露的生成操作和更新操作,图中示出状态空间的第①个~第⑦个状态, 其中标识出用于更新状态向量的状态向量X[i]、X[i+1]和X[i+M]和用于生成随机数的状态向量Y[i+M-1]和Y[i+N]在状态空间中的位置(或者说空间地址)变化。具体地,如前所述,可以基于前述的“MTGPDC”随机数生成算法,通过利用图中所示状态向量Y[i+(m-1)]和Y(i+N)来执行如下操作,以生成随机数O[i]:Fig. 4 is a schematic diagram showing state space changes for generating random numbers according to an embodiment of the present disclosure. In order to facilitate the understanding of the generation operation and update operation of the present disclosure, the figure shows the 1st to 7th states of the state space, where the state vectors X[i] and X[i+1] used to update the state vectors are identified The positions (or space addresses) of X[i+M] and state vectors Y[i+M-1] and Y[i+N] used to generate random numbers in the state space change. Specifically, as mentioned above, based on the aforementioned "MTGPDC" random number generation algorithm, the following operations can be performed by using the state vectors Y[i+(m-1)] and Y(i+N) shown in the figure, to Generate random numbers O[i]:

t=Y[i+(M-1)]^(Y[i+(M-1)]);t=Y[i+(M-1)]^(Y[i+(M-1)]);

t=t^(t>>8);t=t^(t>>8);

O[i]=Y[i+N]^T_table[t&0x4]。O[i]=Y[i+N]^T_table[t&0x4].

接着,可以再基于前述的“MTGPDC”随机数生成算法从状态空间中分别读取前述3个状态向量X[i]、X[i+1]和X[i+M],以生成用于更新的状态向量Y(i+N),其中i、i+1、i+M为该状态向量到状态空间的首地址的距离(即每个状态向量的地址指针)。可以看出,本披露为了实现随机数的流水生成,提出了先执行生成随机数的生成操作,并且接着再执行更新状态向量的更新操作。在一个实施场景中,考虑到运算单元的处理能力和对数据的访存性能,针对于预定(或者称目标)数目的随机数,本披露提出基于多条微指令来交替执行生成操作和更新操作,从而生成预定数目的随机数。Then, based on the aforementioned "MTGPDC" random number generation algorithm, the aforementioned three state vectors X[i], X[i+1], and X[i+M] can be respectively read from the state space to generate The state vector Y(i+N), where i, i+1, and i+M are the distances from the state vector to the first address of the state space (that is, the address pointer of each state vector). It can be seen that, in order to realize the pipelined generation of random numbers, the present disclosure proposes to firstly perform the generation operation of generating random numbers, and then perform the update operation of updating the state vector. In an implementation scenario, considering the processing capability of the computing unit and the memory access performance of the data, for a predetermined (or target) number of random numbers, this disclosure proposes to alternately perform generation operations and update operations based on multiple microinstructions , thereby generating a predetermined number of random numbers.

结合上述内容来具体参考图4,在状态空间的第①状态中,此时状态空间已经完成如前文所述的初始化过程,即从0~N-1个状态向量扩展生成N~2N-1个状态向量,从而获得大小为0~2N-1的状态空间。接着,在所述状态空间的第②状态中,运算单元可以利用状态向量Y[i+M-1]和Y[i+N]来生成96个随机数。为此,第①状态中的状态向量Y[i+M-1]和Y[i+N]在生成随机数的过程中不断向右移,直至状态向量Y[i+N]到达状态空间中“N+96”的空间位置。在生成96个随机数后,接着运算单元可以利用状态向量X[i]、X[i+1]和X[i+M]来生成96个新的状态向量,以更新状态空间,如图中状态空间的第③状态中箭头指示的0~96的区段所示。Referring to Figure 4 in combination with the above content, in the first state of the state space, the state space has completed the initialization process as described above, that is, the state vectors from 0 to N-1 are expanded to generate N to 2N-1 State vector, thus obtaining a state space with a size of 0 to 2N-1. Next, in thestate ② of the state space, the computing unit can use the state vectors Y[i+M-1] and Y[i+N] to generate 96 random numbers. For this reason, the state vectors Y[i+M-1] and Y[i+N] in the first state are continuously moved to the right during the process of generating random numbers until the state vector Y[i+N] reaches the state space The spatial position of "N+96". After generating 96 random numbers, the operation unit can use the state vectors X[i], X[i+1] and X[i+M] to generate 96 new state vectors to update the state space, as shown in the figure In the third state of the state space, it is indicated by the segment of 0 to 96 indicated by the arrow.

如前所述,本披露的状态空间可以分为多个连续分布的读取空间区段和写入空间区段。鉴于此,就图4所示例子而言,状态向量Y[i+M-1]和Y[i+N]在状态空间从第②状态到第③状态期间所移动经过的区段可以视为前述的读取空间区段,而第③状态中所示出的更新96个状态的区段也即前述的写入空间区段。As mentioned above, the state space of the present disclosure can be divided into a plurality of continuously distributed read space segments and write space segments. In view of this, as far as the example shown in Figure 4 is concerned, the segments that state vectors Y[i+M-1] and Y[i+N] move through during the state space fromstate ② tostate ③ can be regarded as The aforementioned read space segment, and the segment for updating 96 states shown in the third state is also the aforementioned write space segment.

接着,在第④状态中,运算单元可以接着沿空间状态向右顺序读取Y[i+M-1]和Y[i+N],以生成96个随机数。由此,第③状态中的Y[i+M-1]将从空间位置“96+M-1”到达第④状态中的空间位置“192+M-1”。相应地,第③状态中的Y[i+N]将从空间位置“N+96”到达第④状态中的空间位置“N+192”。接着,与第③状态类似,在第⑤状态中,运算单元可以利用X[i]、X[i+1]和X[i+M]来生成96个新的状态向量,以更新状态空间,如第⑤状态中箭头指示的“96~192”的区段所示。与上文描述类似,此处的“96~192”区段也即本披露上下文的写入空间区段。Then, instate ④, the arithmetic unit can then sequentially read Y[i+M-1] and Y[i+N] along the space state to the right to generate 96 random numbers. Thus, Y[i+M-1] in the ③ state will reach the spatial position "192+M-1" in the ④ state from the spatial position "96+M-1". Correspondingly, Y[i+N] in the ③ state will reach the spatial position “N+192” in the ④ state from the spatial position “N+96”. Next, similar to the ③ state, in the ⑤ state, the operation unit can use X[i], X[i+1] and X[i+M] to generate 96 new state vectors to update the state space, As shown in the segment "96-192" indicated by the arrow instate ⑤. Similar to the above description, the "96-192" segment here is also the writing space segment in the context of the present disclosure.

与上面的第④状态和第⑤状态相类似,在第⑥状态和第⑦状态中,运算单元可以生成159个随机数,并且更新(N-M-192)个状态向量,也即第⑦状态中箭头指示的“192~(N-M)”的区段所示出的。尽管图4中未进一步示出,可以理解的是此处对于更新(N-M-192)个状态向量,可以根据(M-1)与96的数值比较来采取不同的实现方式。具体地,当(M-1)<=96时,则运算单元可以通过一条微指令来更新(M-1)个状态向量(由此X[i+1]循环返回至状态空间“0”位置处),并且接着利用一条微指令来更新1个状态(由此X[i]循环返回至状态空间“0”位置处)。相对地,当M-1>96时,则可以利用三条微指令来完成更新操作,例如首先更新96个状态,接着更新M-1-96 个状态(由此X[i+1]循环返回至状态空间“0”位置处),并且最后更新1个状态(由此X[i]循环返回至状态空间“0”位置处)。Similar to the ④ state and the ⑤ state above, in the ⑥ state and the ⑦ state, the operation unit can generate 159 random numbers, and update (N-M-192) state vectors, that is, the arrow in the ⑦ state The section indicated "192~(N-M)" is shown. Although not further shown in FIG. 4 , it can be understood that for updating (N-M-192) state vectors here, different implementations may be adopted according to the numerical comparison between (M-1) and 96 . Specifically, when (M-1)<=96, the operation unit can update (M-1) state vectors (thus X[i+1] loops back to the state space "0" position by a microinstruction ), and then update 1 state with one microinstruction (thus X[i] loops back to state space "0" location). In contrast, when M-1>96, then three microinstructions can be used to complete the update operation, for example,first update 96 states, and then update M-1-96 states (thus X[i+1] loops back to state space "0" position), and finally update 1 state (thus X[i] loops back to state space "0" position).

通过利用上面结合图4所描述的本披露的随机数方案,可以克服现有对存储器的读和写操作期间的空闲等待时间(例如更新后需等待一定时间才能读取),从而可以利用该时间来执行生成随机数的操作。具体地,本披露通过扩展状态空间并且将其划分成克服地址依赖性的不同访存区段,并且通过先执行生成操作而后执行更新操作,从而实现硬件流水并且高效地生成随机数。By utilizing the random number scheme of the present disclosure described above in conjunction with FIG. 4, the existing idle latency during read and write operations to the memory (e.g., waiting for a certain amount of time after an update to read) can be overcome, thereby making it possible to utilize to perform the operation of generating random numbers. Specifically, the present disclosure implements hardware pipelining and efficiently generates random numbers by expanding the state space and dividing it into different memory access segments that overcome address dependencies, and by performing generation operations first and then update operations.

图5a是示出根据本披露又一个实施例的用于生成随机数的部分状态空间变化的示意图,而图5b是示出根据前述实施例的用于生成随机数的另一部分状态空间变化的示意图。在一个实施方式中,图5a和图5b中所示出的生成操作和更新操作可以由前述的“大核”来执行。相较而言,图4中所示出的生成操作和更新操作可以由前述的“小核”来执行。Fig. 5a is a schematic diagram illustrating a partial state space change for generating a random number according to yet another embodiment of the present disclosure, and Fig. 5b is a schematic diagram illustrating another part of the state space change for generating a random number according to the foregoing embodiment . In one embodiment, the generation and update operations shown in Figures 5a and 5b may be performed by the aforementioned "big core". In comparison, the generation operation and update operation shown in FIG. 4 can be performed by the aforementioned "small core".

如图5a所示,在第①和第②状态中,运算单元可以利用两条微指令来首先生成192个随机数,并且接着更新状态空间中的192个状态向量,其位置如图第②状态中的箭头所示区段。接着,运算单元可以顺序执行四条微指令,从而在第③状态中生成159个随机数,并且在第④状态到第⑥状态中分别更新(N-M-192)、(M-1)和1个状态向量。As shown in Figure 5a, instates ① and ②, the arithmetic unit can use two microinstructions to first generate 192 random numbers, and then update 192 state vectors in the state space, as shown instate ② The section indicated by the arrow in . Then, the arithmetic unit can execute four microinstructions sequentially, thereby generating 159 random numbers in the ③ state, and updating (N-M-192), (M-1) and 1 state respectively in the ④ state to the ⑥ state vector.

接着,如图5b所示,在第⑦和第⑧状态中,运算单元接着可以生成192个随机数,并且接着更新192个状态向量。与上文描述相同,运算单元可以借助于两条微指令来分别完成前述操作。接着,在第⑨状态到第

Figure PCTCN2022096725-appb-000001
状态期间,运算单元可以依次完成生成(160-M)个随机数,生成(M-1)个随机数,以及更新159个状态向量的操作。Next, as shown in FIG. 5 b , instates ⑦ and ⑧, the computing unit can then generate 192 random numbers, and then update 192 state vectors. Same as the above description, the operation unit can respectively complete the aforementioned operations by means of two microinstructions. Then, in the ninth state to the
Figure PCTCN2022096725-appb-000001
During the state period, the operation unit can sequentially complete the operations of generating (160-M) random numbers, generating (M-1) random numbers, and updating 159 state vectors.

鉴于在前已经结合图4对用于生成随机数的状态向量和用于更新状态空间的状态向量在状态空间中的地址变化进行了描述,此处为了简明的目的而不再赘述。另外,尽管图4和图5以N=351(即2N=702)为例来描述本披露的生成操作和更新操作,本领域技术人员基于本披露的教导可以理解此处N的数值可以依硬件(如运算单元和存储器)的处理能力来进行改变。进一步,用于执行生成操作和更新操作的微指令及其数目也可以根据硬件架构来进行相应的适配。Since the address change of the state vector used to generate random numbers and the state vector used to update the state space in the state space has been described in conjunction with FIG. 4 , details are not repeated here for the purpose of brevity. In addition, although FIG. 4 and FIG. 5 use N=351 (that is, 2N=702) as an example to describe the generation operation and update operation of the present disclosure, those skilled in the art can understand that the value of N here can be determined by the hardware based on the teaching of the present disclosure. (such as arithmetic unit and memory) to change the processing power. Further, the microinstructions and their numbers for performing the generation operation and the update operation can also be adapted accordingly according to the hardware architecture.

图6是示出根据本披露实施例的用于生成随机数的方法600的流程图。基于前文结合图1-图5对本披露方案的描述,本领域技术人员可以理解图6所示方法可以由图1所示的装置100来实现,因此关于装置100的操作所进行的描述也同样适用于方法600的步骤操作,并且相同的内容将不再赘述。FIG. 6 is a flowchart illustrating amethod 600 for generating random numbers according to an embodiment of the present disclosure. Based on the foregoing description of the present disclosure in conjunction with FIGS. 1-5 , those skilled in the art can understand that the method shown in FIG. 6 can be implemented by thedevice 100 shown in FIG. 1 , and therefore the description about the operation of thedevice 100 is also applicable. Operations in the steps ofmethod 600, and the same content will not be repeated.

如图6所示,在步骤S602处,接收随机数指令并且对该随机数指令进行译码。这里,随机数指令包括关于生成随机数的各类信息,并且译码可以涉及对随机数指令的解析,从而可以获得多条微指令。接着,在步骤S604处,可以根据译码后的所述随机数指令来设置状态空间,其中状态空间配置成存储用于生成随机数的状态向量并且接受对状态空间的状态向量更新。这里,状态空间可以具有前文结合图4、图5a和图5b所描述的示例形式。最后,在步骤S606处,可以根据译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,随机数生成操作包括以流水方式执行的生成操作和更新操作,其中生成操作用于生成随机数并且所述更新操作用于更新状态向量。在一个实施例中,状态空间的大小可以设置成在 单个或多个种子下支持以流水方式执行所述生成操作和更新操作。As shown in FIG. 6, at step S602, a random number instruction is received and the random number instruction is decoded. Here, the random number instruction includes various information about generating the random number, and the decoding may involve analyzing the random number instruction, so as to obtain multiple microinstructions. Next, at step S604, a state space may be set according to the decoded random number instruction, wherein the state space is configured to store state vectors for generating random numbers and accept state vector updates to the state space. Here, the state space may have the example form described above in connection with Fig. 4, Fig. 5a and Fig. 5b. Finally, at step S606, a random number generation operation based on a single seed or multiple seeds can be performed according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes A generate operation and an update operation, wherein the generate operation is used to generate random numbers and the update operation is used to update the state vector. In one embodiment, the state space can be sized to support pipelined execution of the generate and update operations under single or multiple seeds.

图7是示出根据本披露实施例的单种子模式下生成随机数的方法700的流程图。为了便于理解和讨论该流程,图中还示意性的示出单个种子下的状态空间,其包括0~2N-1个状态向量。FIG. 7 is a flowchart illustrating amethod 700 for generating random numbers in a single-seed mode according to an embodiment of the present disclosure. In order to facilitate understanding and discussion of the process, the figure also schematically shows a state space under a single seed, which includes 0˜2N−1 state vectors.

如图7所示,在步骤S702处,可以首先利用种子来生成N个状态向量,从而初始化状态空间中的N个状态。接着,在步骤S704处,可以利用随机数生成算法中的更新操作来更新状态,从而将0~N-1的状态子空间扩展到N~2N-1的状态子空间,由此得到具有2N个状态向量的状态空间。接着,可以在步骤S706处和S708处执行前述的生成操作和更新操作,以生成随机数并且更新状态空间。当还未生成预定数目的随机数时,则可以接着执行步骤S710和S712,以接着生成预定部分数目的随机数。类似地,还可以反复执行生成操作和更新操作,直到生成预定数目的随机数。As shown in FIG. 7 , at step S702 , the seeds may be used first to generate N state vectors, thereby initializing N states in the state space. Next, at step S704, the update operation in the random number generation algorithm can be used to update the state, thereby expanding the state subspace of 0 ~ N-1 to the state subspace of N ~ 2N-1, thus obtaining the state subspace with 2N State space of state vectors. Next, the aforementioned generating operation and updating operation may be performed at steps S706 and S708 to generate random numbers and update the state space. When the predetermined number of random numbers has not been generated, steps S710 and S712 may be performed next to generate a predetermined partial number of random numbers. Similarly, generating operations and updating operations may also be repeatedly performed until a predetermined number of random numbers are generated.

图8是示出根据本披露实施例的双种子模式下生成随机数的方法800的流程图。基于前文的描述,可以理解的是图8所示方法800可以由图1所示的装置100来执行,因此前文对装置100及其生成操作和更新操作的描述也同样适用于方法800的下面描述。另外,为了便于描述,图8中还示出了与第一种子和第二种子各自相关的状态空间,并且每个状态空间具有容纳0~2N-1共2N个状态向量。FIG. 8 is a flowchart illustrating amethod 800 for generating random numbers in a dual-seed mode according to an embodiment of the present disclosure. Based on the foregoing description, it can be understood that themethod 800 shown in FIG. 8 can be executed by thedevice 100 shown in FIG. 1 , so the foregoing descriptions of thedevice 100 and its generating and updating operations are also applicable to the following description of themethod 800 . In addition, for ease of description, FIG. 8 also shows state spaces related to the first seed and the second seed, and each state space has 2N state vectors containing 0˜2N−1.

如图8所示,在步骤S802和S804处,可以初始化第一种子状态空间中的N个状态向量,并且接着仅执行更新操作以将N个状态向量扩大到2N个状态向量。类似地,在步骤S806和S808处,也执行关于第二种子的状态空间的初始化操作,以得到包含2N个初始状态的状态向量。As shown in FIG. 8, at steps S802 and S804, N state vectors in the first sub-state space may be initialized, and then only an update operation is performed to expand the N state vectors to 2N state vectors. Similarly, at steps S806 and S808, an initialization operation on the state space of the second seed is also performed to obtain a state vector including 2N initial states.

接着,在步骤S810和S812处,分别执行关于第一种子的生成随机数的生成操作和用于更新状态空间的更新操作。在执行完第一种子后,接着在步骤S814和S816处执行关于第二种子的生成随机数的操作和更新状态空间的操作。假定此时还未达到与第一种子和第二种子关联的随机数的预定数目,可以接着在步骤S818和S820处,接着生成部分数目的随机数并且相应地更新相同部分数目的状态向量。同样地,在步骤S822和S824处,接着执行关于第二种子的生成随机数的操作和更新状态空间。当仍未达到预定数目的随机数时,关于第一种子和第二种子的生成随机数和更新状态空间的操作将仍交替执行,直到生成预定数目的随机数为止。Next, at steps S810 and S812, a generating operation for generating a random number and an updating operation for updating the state space with respect to the first seed are respectively performed. After the first seed is executed, the operation of generating random numbers and the operation of updating the state space with respect to the second seed are then performed at steps S814 and S816. Assuming that the predetermined number of random numbers associated with the first seed and the second seed has not been reached at this time, a partial number of random numbers may then be generated and the same partial number of state vectors may be updated accordingly at steps S818 and S820. Likewise, at steps S822 and S824, the operation of generating a random number and updating the state space with respect to the second seed are then performed. When the predetermined number of random numbers has not yet been reached, the operations of generating random numbers and updating the state space with respect to the first seed and the second seed will still be performed alternately until a predetermined number of random numbers are generated.

在一个实施场景中,当针对于第一种子和第二种子同时执行生成随机数的操作时,可以在本披露的随机数指令中设置与第一种子关联的随机数的存储地址。这样,运算单元就可以在生成与第二种子关联的随机数时,根据前述的存储地址将与第二种子关联的随机数放置在与第一种子关联的随机数之后。特别地,由于运算单元会以乒乓流水的方式来生成第一种子和第二种子的随机数,因此可以提前基于第一种子随机数的存储地址和生成的数目来计算出用于存储第二种子所生成的随机数的首地址。In an implementation scenario, when the operation of generating a random number is performed on the first seed and the second seed at the same time, the storage address of the random number associated with the first seed may be set in the random number instruction of the present disclosure. In this way, when generating the random number associated with the second seed, the arithmetic unit can place the random number associated with the second seed after the random number associated with the first seed according to the aforementioned storage address. In particular, since the operation unit will generate the random numbers of the first seed and the second seed in a ping-pong manner, it can be calculated in advance based on the storage address of the first seed random number and the generated number for storing the second seed The first address of the generated random number.

在一个实施场景中,对于后续将不再使用的种子,本披露的随机数指令中也可以包含关于启用或禁用种子的设置项。基于此,在启用时(例如将启用标志位设为1),可以对该种子的状态空间进行初始化(例如从N个状态扩大至2N个状态);相对地,当禁用时(例如将禁用标志位设为1),则在利用该种子生成预定数目的随机数后,删除与该种子相关的设置和状态空间。在另一个实施场景中,还可以在随机数指令中设置跳过的状态数。基于此,当执行基于第一种子和/或第二种子的生成随机数的操作 中时,可以跳过或放弃状态空间中的一些状态向量,例如生成用于更新的状态向量,但并不向状态空间写入,直到获得预期位置的状态向量,并且在该位置开始执行生成操作和更新操作。In an implementation scenario, for a seed that will not be used later, the random number instruction of the present disclosure may also include a setting item about enabling or disabling the seed. Based on this, when enabled (for example, the enable flag is set to 1), the state space of the seed can be initialized (for example, expanded from N states to 2N states); relatively, when disabled (for example, the disable flag bit is set to 1), then after a predetermined number of random numbers are generated using the seed, the setup and state spaces associated with the seed are deleted. In another implementation scenario, the number of skipped states can also be set in the random number instruction. Based on this, when performing the operation of generating random numbers based on the first seed and/or the second seed, some state vectors in the state space can be skipped or discarded, such as generating state vectors for updating, but not to The state space is written until the state vector at the desired location is obtained, and generation and update operations begin at that location.

图9是示出根据本披露实施例的一种组合处理装置900的结构图。如图9中所示,该组合处理装置900包括计算处理装置902、接口装置904、其他处理装置906和存储装置908。根据不同的应用场景,计算处理装置中可以包括一个或多个计算装置910,该计算装置可以配置用于执行本文结合附图1-图8所描述的用于生成随机数的生成操作和用于更新状态空间的更新操作。FIG. 9 is a structural diagram showing a combinedprocessing device 900 according to an embodiment of the present disclosure. As shown in FIG. 9 , the combinedprocessing device 900 includes a computing processing device 902 , aninterface device 904 , other processing devices 906 and astorage device 908 . According to different application scenarios, the computing processing device may include one ormore computing devices 910, which may be configured to execute the generating operations for generating random numbers described herein in conjunction with Figs. 1-8 and for An update operation that updates the state space.

在不同的实施例中,本披露的计算处理装置可以配置成执行用户指定的操作。在示例性的应用中,该计算处理装置可以实现为单核人工智能处理器或者多核人工智能处理器。类似地,包括在计算处理装置内的一个或多个计算装置可以实现为人工智能处理器核或者人工智能处理器核的部分硬件结构。当多个计算装置实现为人工智能处理器核或人工智能处理器核的部分硬件结构时,就本披露的计算处理装置而言,其可以视为具有单核结构或者同构多核结构。In various embodiments, the computing processing device of the present disclosure may be configured to perform user-specified operations. In an exemplary application, the computing processing device may be implemented as a single-core artificial intelligence processor or a multi-core artificial intelligence processor. Similarly, one or more computing devices included in the computing processing device may be implemented as an artificial intelligence processor core or a partial hardware structure of an artificial intelligence processor core. When multiple computing devices are implemented as artificial intelligence processor cores or partial hardware structures of artificial intelligence processor cores, as far as the computing processing devices of the present disclosure are concerned, they can be regarded as having a single-core structure or a homogeneous multi-core structure.

在示例性的操作中,本披露的计算处理装置可以通过接口装置与其他处理装置进行交互,以共同完成用户指定的操作。根据实现方式的不同,本披露的其他处理装置可以包括中央处理器(Central Processing Unit,CPU)、图形处理器(Graphics Processing Unit,GPU)、人工智能处理器等通用和/或专用处理器中的一种或多种类型的处理器。这些处理器可以包括但不限于数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等,并且其数目可以根据实际需要来确定。如前所述,仅就本披露的计算处理装置而言,其可以视为具有单核结构或者同构多核结构。然而,当将计算处理装置和其他处理装置共同考虑时,二者可以视为形成异构多核结构。In an exemplary operation, the computing processing device of the present disclosure may interact with other processing devices through the interface device, so as to jointly complete operations specified by the user. According to different implementations, other processing devices of the present disclosure may include central processing units (Central Processing Unit, CPU), graphics processing units (Graphics Processing Unit, GPU), artificial intelligence processors and other general-purpose and/or special-purpose processors. One or more types of processors. These processors can include but are not limited to Digital Signal Processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable Logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., and the number thereof can be determined according to actual needs. As mentioned above, as far as the computing processing device of the present disclosure is concerned, it can be regarded as having a single-core structure or a homogeneous multi-core structure. However, when computing processing devices and other processing devices are considered together, the two can be viewed as forming a heterogeneous multi-core structure.

在一个或多个实施例中,该其他处理装置可以作为本披露的计算处理装置与外部数据和控制的接口,执行包括但不限于数据搬运、对计算装置的开启和/或停止等基本控制。在另外的实施例中,其他处理装置也可以和该计算处理装置协作以共同完成运算任务。In one or more embodiments, the other processing device can serve as an interface between the computing processing device of the present disclosure and external data and control, and perform basic control including but not limited to data transfer, starting and/or stopping the computing device, etc. In other embodiments, other processing devices may also cooperate with the computing processing device to jointly complete computing tasks.

在一个或多个实施例中,该接口装置可以用于在计算处理装置与其他处理装置间传输数据和控制指令。例如,该计算处理装置可以经由所述接口装置从其他处理装置中获取输入数据,写入该计算处理装置片上的存储装置(或称存储器)。进一步,该计算处理装置可以经由所述接口装置从其他处理装置中获取控制指令,写入计算处理装置片上的控制缓存中。替代地或可选地,接口装置也可以读取计算处理装置的存储装置中的数据并传输给其他处理装置。In one or more embodiments, the interface device may be used to transfer data and control instructions between the computing processing device and other processing devices. For example, the computing processing device may obtain input data from other processing devices via the interface device, and write it into a storage device (or memory) on-chip of the computing processing device. Further, the computing processing device can obtain control instructions from other processing devices via the interface device, and write them into the control buffer on-chip of the computing processing device. Alternatively or optionally, the interface device can also read the data in the storage device of the computing processing device and transmit it to other processing devices.

附加地或可选地,本披露的组合处理装置还可以包括存储装置。如图中所示,该存储装置分别与所述计算处理装置和所述其他处理装置连接。在一个或多个实施例中,存储装置可以用于保存所述计算处理装置和/或所述其他处理装置的数据。例如,该数据可以是在计算处理装置或其他处理装置的内部或片上存储装置中无法全部保存的数据。Additionally or alternatively, the combined processing device of the present disclosure may further include a storage device. As shown in the figure, the storage device is respectively connected to the computing processing device and the other processing device. In one or more embodiments, storage means may be used to store data of said computational processing means and/or said other processing means. For example, the data may be data that cannot all be stored in an internal or on-chip storage device of a computing processing device or other processing device.

在一些实施例里,本披露还公开了一种芯片(例如图10中示出的芯片1002)。 在一种实现中,该芯片是一种系统级芯片(System on Chip,SoC),并且集成有一个或多个如图9中所示的组合处理装置。该芯片可以通过对外接口装置(如图10中示出的对外接口装置1006)与其他相关部件相连接。该相关部件可以例如是摄像头、显示器、鼠标、键盘、网卡或wifi接口。在一些应用场景中,该芯片上可以集成有其他处理单元(例如视频编解码器)和/或接口模块(例如DRAM接口)等。在一些实施例中,本披露还公开了一种芯片封装结构,其包括了上述芯片。在一些实施例里,本披露还公开了一种板卡或一种电子设备,其包括上述的芯片封装结构。下面将结合图10对该板卡进行详细地描述。In some embodiments, the present disclosure also discloses a chip (eg,chip 1002 shown in FIG. 10 ). In one implementation, the chip is a system-on-chip (System on Chip, SoC), and is integrated with one or more combined processing devices as shown in FIG. 9 . The chip can be connected with other relevant components through an external interface device (such as the external interface device 1006 shown in FIG. 10 ). The relevant component may be, for example, a camera, a display, a mouse, a keyboard, a network card or a wifi interface. In some application scenarios, other processing units (such as video codecs) and/or interface modules (such as DRAM interfaces) may be integrated on the chip. In some embodiments, the present disclosure also discloses a chip packaging structure, which includes the above-mentioned chip. In some embodiments, the present disclosure also discloses a board or an electronic device, which includes the above-mentioned chip packaging structure. The board will be described in detail below with reference to FIG. 10 .

图10是示出根据本披露实施例的一种板卡1000的结构示意图。如图8中所示,该板卡包括用于存储数据的存储器件1004,其包括一个或多个存储单元1010。该存储器件可以通过例如总线等方式与控制器件1008和上文所述的芯片1002进行连接和数据传输。进一步,该板卡还包括对外接口装置1006,其配置用于芯片(或芯片封装结构中的芯片)与外部设备1012(例如服务器或计算机等)之间的数据中继或转接功能。例如,待处理的数据可以由外部设备通过对外接口装置传递至芯片。又例如,所述芯片的计算结果可以经由所述对外接口装置传送回外部设备。根据不同的应用场景,所述对外接口装置可以具有不同的接口形式,例如其可以采用标准PCIE接口等。FIG. 10 is a schematic structural diagram showing aboard 1000 according to an embodiment of the present disclosure. As shown in FIG. 8 , the board includes astorage device 1004 for storing data, which includes one ormore storage units 1010 . The storage device can be connected and data transmitted with thecontrol device 1008 and the above-mentionedchip 1002 through, for example, a bus. Further, the board also includes an external interface device 1006 configured for data relay or switching between the chip (or a chip in a chip packaging structure) and an external device 1012 (such as a server or a computer, etc.). For example, the data to be processed can be transmitted to the chip by the external device through the external interface device. For another example, the calculation result of the chip may be transmitted back to the external device via the external interface device. According to different application scenarios, the external interface device may have different interface forms, for example, it may adopt a standard PCIE interface or the like.

在一个或多个实施例中,本披露板卡中的控制器件可以配置用于对所述芯片的状态进行调控。为此,在一个应用场景中,该控制器件可以包括单片机(Micro Controller Unit,MCU),以用于对所述芯片的工作状态进行调控。In one or more embodiments, the control device in the board of the present disclosure may be configured to regulate the state of the chip. For this reason, in an application scenario, the control device may include a single-chip microcomputer (Micro Controller Unit, MCU), for regulating the working state of the chip.

根据上述结合图9和图10的描述,本领域技术人员可以理解本披露也公开了一种电子设备或装置,其可以包括一个或多个上述板卡、一个或多个上述芯片和/或一个或多个上述组合处理装置。According to the above description in conjunction with FIG. 9 and FIG. 10 , those skilled in the art can understand that this disclosure also discloses an electronic device or device, which may include one or more of the above-mentioned boards, one or more of the above-mentioned chips and/or one or more than one of the above combined processing devices.

根据不同的应用场景,本披露的电子设备或装置可以包括服务器、云端服务器、服务器集群、数据处理装置、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、PC设备、物联网终端、移动终端、手机、行车记录仪、导航仪、传感器、摄像头、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、视觉终端、自动驾驶终端、交通工具、家用电器、和/或医疗设备。所述交通工具包括飞机、轮船和/或车辆;所述家用电器包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机;所述医疗设备包括核磁共振仪、B超仪和/或心电图仪。本披露的电子设备或装置还可以被应用于互联网、物联网、数据中心、能源、交通、公共管理、制造、教育、电网、电信、金融、零售、工地、医疗等领域。进一步,本披露的电子设备或装置还可以用于云端、边缘端、终端等与人工智能、大数据和/或云计算相关的应用场景中。在一个或多个实施例中,根据本披露方案的算力高的电子设备或装置可以应用于云端设备(例如云端服务器),而功耗小的电子设备或装置可以应用于终端设备和/或边缘端设备(例如智能手机或摄像头)。在一个或多个实施例中,云端设备的硬件信息和终端设备和/或边缘端设备的硬件信息相互兼容,从而可以根据终端设备和/或边缘端设备的硬件信息,从云端设备的硬件资源中匹配出合适的硬件资源来模拟终端设备和/或边缘端设备的硬件资源,以便完成端云一体或云边端一体的统一管理、调度和协同工作。According to different application scenarios, the electronic equipment or devices disclosed in this disclosure may include servers, cloud servers, server clusters, data processing devices, robots, computers, printers, scanners, tablet computers, smart terminals, PC equipment, IoT terminals, mobile Terminals, mobile phones, driving recorders, navigators, sensors, cameras, cameras, video cameras, projectors, watches, earphones, mobile storage, wearable devices, visual terminals, automatic driving terminals, vehicles, household appliances, and/or medical equipment. Said vehicles include airplanes, ships and/or vehicles; said household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, range hoods; said medical equipment includes nuclear magnetic resonance instruments, Ultrasound and/or electrocardiograph. The electronic equipment or device disclosed herein can also be applied to fields such as the Internet, the Internet of Things, data centers, energy, transportation, public management, manufacturing, education, power grids, telecommunications, finance, retail, construction sites, and medical treatment. Further, the electronic device or device disclosed herein can also be used in application scenarios related to artificial intelligence, big data and/or cloud computing, such as cloud, edge, and terminal. In one or more embodiments, electronic devices or devices with high computing power according to the disclosed solutions can be applied to cloud devices (such as cloud servers), while electronic devices or devices with low power consumption can be applied to terminal devices and/or Edge devices (such as smartphones or cameras). In one or more embodiments, the hardware information of the cloud device and the hardware information of the terminal device and/or the edge device are compatible with each other, so that according to the hardware information of the terminal device and/or the edge device, the hardware resources of the cloud device can be Match appropriate hardware resources to simulate the hardware resources of terminal devices and/or edge devices, so as to complete the unified management, scheduling and collaborative work of device-cloud integration or cloud-edge-end integration.

需要说明的是,为了简明的目的,本披露将一些方法及其实施例表述为一系列的 动作及其组合,但是本领域技术人员可以理解本披露的方案并不受所描述的动作的顺序限制。因此,依据本披露的公开或教导,本领域技术人员可以理解其中的某些步骤可以采用其他顺序来执行或者同时执行。进一步,本领域技术人员可以理解本披露所描述的实施例可以视为可选实施例,即其中所涉及的动作或模块对于本披露某个或某些方案的实现并不一定是必需的。另外,根据方案的不同,本披露对一些实施例的描述也各有侧重。鉴于此,本领域技术人员可以理解本披露某个实施例中没有详述的部分,也可以参见其他实施例的相关描述。It should be noted that, for the purpose of brevity, the present disclosure expresses some methods and their embodiments as a series of actions and combinations thereof, but those skilled in the art can understand that the solution of the present disclosure is not limited by the order of the described actions . Therefore, according to the disclosure or teaching of the present disclosure, those skilled in the art may understand that certain steps may be performed in other orders or simultaneously. Further, those skilled in the art can understand that the embodiments described in the present disclosure can be regarded as optional embodiments, that is, the actions or modules involved therein are not necessarily required for the realization of one or some solutions of the present disclosure. In addition, according to different schemes, the description of some embodiments in this disclosure also has different emphases. In view of this, those skilled in the art may understand the part that is not described in detail in a certain embodiment of the present disclosure, and may also refer to related descriptions of other embodiments.

在具体实现方面,基于本披露的公开和教导,本领域技术人员可以理解本披露所公开的若干实施例也可以通过本文未公开的其他方式来实现。例如,就前文所述的电子设备或装置实施例中的各个单元来说,本文在考虑了逻辑功能的基础上对其进行划分,而实际实现时也可以有另外的划分方式。又例如,可以将多个单元或组件结合或者集成到另一个系统,或者对单元或组件中的一些特征或功能进行选择性地禁用。就不同单元或组件之间的连接关系而言,前文结合附图所讨论的连接可以是单元或组件之间的直接或间接耦合。在一些场景中,前述的直接或间接耦合涉及利用接口的通信连接,其中通信接口可以支持电性、光学、声学、磁性或其它形式的信号传输。In terms of specific implementation, based on the disclosure and teachings of the present disclosure, those skilled in the art may understand that several embodiments disclosed in the present disclosure may also be implemented in other ways not disclosed herein. For example, with regard to the various units in the aforementioned electronic device or device embodiments, this paper divides them on the basis of considering logical functions, but there may be other division methods in actual implementation. As another example, multiple units or components may be combined or integrated into another system, or some features or functions in units or components may be selectively disabled. As far as the connection relationship between different units or components is concerned, the connections discussed above in conjunction with the drawings may be direct or indirect couplings between units or components. In some scenarios, the aforementioned direct or indirect coupling involves a communication connection using an interface, where the communication interface may support electrical, optical, acoustic, magnetic or other forms of signal transmission.

在本披露中,作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元示出的部件可以是或者也可以不是物理单元。前述部件或单元可以位于同一位置或者分布到多个网络单元上。另外,根据实际的需要,可以选择其中的部分或者全部单元来实现本披露实施例所述方案的目的。另外,在一些场景中,本披露实施例中的多个单元可以集成于一个单元中或者各个单元物理上单独存在。In the present disclosure, a unit described as a separate component may or may not be physically separated, and a component shown as a unit may or may not be a physical unit. The aforementioned components or units may be located at the same location or distributed over multiple network units. In addition, according to actual needs, some or all of the units may be selected to achieve the purpose of the solutions described in the embodiments of the present disclosure. In addition, in some scenarios, multiple units in the embodiments of the present disclosure may be integrated into one unit, or each unit exists physically independently.

在一些实现场景中,上述集成的单元可以采用软件程序模块的形式来实现。如果以软件程序模块的形式实现并作为独立的产品销售或使用时,所述集成的单元可以存储在计算机可读取存储器中。基于此,当本披露的方案以软件产品(例如计算机可读存储介质)的形式体现时,该软件产品可以存储在存储器中,其可以包括若干指令用以使得计算机设备(例如个人计算机、服务器或者网络设备等)执行本披露实施例所述方法的部分或全部步骤。前述的存储器可以包括但不限于U盘、闪存盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。In some implementation scenarios, the above integrated units may be implemented in the form of software program modules. If implemented in the form of a software program module and sold or used as a stand-alone product, the integrated unit may be stored in a computer readable memory. Based on this, when the solution of the present disclosure is embodied in the form of a software product (such as a computer-readable storage medium), the software product can be stored in a memory, and it can include several instructions to make a computer device (such as a personal computer, a server, or Network devices, etc.) execute some or all of the steps of the methods described in the embodiments of the present disclosure. The aforementioned memory may include but not limited to U disk, flash disk, read-only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), mobile hard disk, magnetic disk or optical disk, etc., which can store programs. The medium of the code.

在另外一些实现场景中,上述集成的单元也可以采用硬件的形式实现,即为具体的硬件电路,其可以包括数字电路和/或模拟电路等。电路的硬件结构的物理实现可以包括但不限于物理器件,而物理器件可以包括但不限于晶体管或忆阻器等器件。鉴于此,本文所述的各类装置(例如计算装置或其他处理装置)可以通过适当的硬件处理器来实现,例如CPU、GPU、FPGA、DSP和ASIC等。进一步,前述的所述存储单元或存储装置可以是任意适当的存储介质(包括磁存储介质或磁光存储介质等),其例如可以是可变电阻式存储器(Resistive Random Access Memory,RRAM)、动态随机存取存储器(Dynamic Random Access Memory,DRAM)、静态随机存取存储器(Static Random Access Memory,SRAM)、增强动态随机存取存储器(Enhanced Dynamic Random Access Memory,EDRAM)、高带宽存储器(High Bandwidth Memory,HBM)、混合存储器立方体(Hybrid Memory Cube,HMC)、ROM和RAM等。In other implementation scenarios, the above-mentioned integrated units may also be implemented in the form of hardware, that is, specific hardware circuits, which may include digital circuits and/or analog circuits. The physical realization of the hardware structure of the circuit may include but not limited to physical devices, and the physical devices may include but not limited to devices such as transistors or memristors. In view of this, various devices (such as computing devices or other processing devices) described herein may be implemented by appropriate hardware processors, such as CPU, GPU, FPGA, DSP, and ASIC. Further, the aforementioned storage unit or storage device can be any suitable storage medium (including magnetic storage medium or magneto-optical storage medium, etc.), which can be, for example, a variable resistance memory (Resistive Random Access Memory, RRAM), dynamic Random Access Memory (Dynamic Random Access Memory, DRAM), Static Random Access Memory (Static Random Access Memory, SRAM), Enhanced Dynamic Random Access Memory (Enhanced Dynamic Random Access Memory, EDRAM), High Bandwidth Memory (High Bandwidth Memory , HBM), hybrid memory cube (Hybrid Memory Cube, HMC), ROM and RAM, etc.

依据以下条款可更好地理解前述内容:The foregoing can be better understood in light of the following terms:

条款A1、一种用于生成随机数的装置,包括:Clause A1. An apparatus for generating random numbers, comprising:

指令译码单元,其配置成接收随机数指令并且对所述随机数指令进行译码;an instruction decoding unit configured to receive a random number instruction and decode the random number instruction;

运算单元,其配置成根据所述译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量;以及an arithmetic unit configured to perform a random number generation operation based on a single seed or a plurality of seeds according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes performing a generate operation and an update operation, wherein the generate operation is used to generate a random number and the update operation is used to update a state vector; and

存储器,其配置成根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受来自运算单元对所述状态空间的状态向量更新,a memory configured to set up a state space according to the decoded random number instruction, wherein the state space is configured to store a state vector used to generate the random number and accept a state of the state space from an arithmetic unit vector update,

其中所述状态空间的大小设置成:Wherein the size of the state space is set as:

在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者Under a single seed, the generation operation and the update operation are supported to be performed in a pipelined manner; or

在多个种子下,支持以流水方式执行各个种子的随机数生成操作。Under multiple seeds, the random number generation operation of each seed is supported in a pipelined manner.

条款A2、根据条款A1所述的装置,其中所述随机数指令包括以下中的一项或多项:生成随机数的数目、状态空间的大小和地址、用于生成随机数的一个或多个种子信息、用于拼接随机数的拼接参数和输出随机数的地址。Clause A2. The apparatus of Clause A1, wherein the random number instruction includes one or more of: the number of random numbers to generate, the size and address of the state space, one or more Seed information, splicing parameters for splicing random numbers and address of outputting random numbers.

条款A3、根据条款A1所述的装置,其中所述随机数指令是单个指令并且经所述指令译码单元解析后得到用于执行流水操作的多个微指令,其中所述运算单元配置成:Clause A3. The device according to Clause A1, wherein the random number instruction is a single instruction and is parsed by the instruction decoding unit to obtain a plurality of microinstructions for performing pipeline operations, wherein the operation unit is configured to:

根据所述微指令,以循环移位的方式沿所述状态空间来执行生成随机数的生成操作和更新所述状态空间的更新操作。According to the microinstruction, a generating operation for generating a random number and an updating operation for updating the state space are performed along the state space in a circular shift manner.

条款A4、根据条款A3所述的装置,其中所述微指令包括用于所述生成操作的生成微指令和用于所述更新操作的更新微指令,并且所述生成微指令和更新微指令与所述生成操作和更新操作所涉及的状态空间位置相关,并且所述运算单元配置成以下面操作之一来生成部分数目的随机数:Clause A4. The apparatus of Clause A3, wherein said microinstructions comprise a generate microinstruction for said generate operation and an update microinstruction for said update operation, and said generate microinstruction and update microinstruction are related to The generation operation is related to the state space position involved in the update operation, and the operation unit is configured to generate a partial number of random numbers by one of the following operations:

根据一个生成微指令来生成部分数目的随机数,并且根据一个更新微指令来更新部分数目的状态向量;或者generating a partial number of random numbers according to a generate uop, and updating a partial number of state vectors according to an update uop; or

根据一个生成微指令来生成部分数目的随机数,并且根据多个更新微指令来分别更新部分数目的状态向量;或者generating a partial number of random numbers according to a generating microinstruction, and updating a partial number of state vectors respectively according to a plurality of updating microinstructions; or

根据多个生成微指令来分别生成部分数目的随机数,并且根据一个更新微指令来生成部分数目的随机数。A partial number of random numbers is respectively generated according to a plurality of generation microinstructions, and a partial number of random numbers is generated according to an update microinstruction.

条款A5、根据条款A3所述的装置,其中每个所述微指令包括指示针对状态空间的读取操作或写入操作的地址范围项,并且对于地址范围项存在地址交叠的两条连续微指令,所述运算单元配置成:Clause A5. The apparatus of clause A3, wherein each of said microinstructions includes an address range entry indicating a read operation or a write operation to the state space, and there are two consecutive microinstructions with overlapping addresses for the address range entry instruction, the operation unit is configured to:

仅在执行完其中一条微指令的读取操作或写入操作后,才执行下一条微指令的读取操作或写入操作。Only after the read or write operation of one microinstruction is executed, the read or write operation of the next microinstruction is executed.

条款A6、根据条款A1所述的装置,其中所述状态空间的大小由软件来配置,以便使得在单个种子下的所述生成操作和更新操作以流水方式执行,并且使得在多个种子下的随机数生成操作以流水方式执行。Clause A6. The apparatus of clause A1, wherein the size of the state space is configured by software such that the generation and update operations under a single seed are performed in a pipelined manner, and that the Random number generation operations are performed in a pipelined manner.

条款A7、根据条款A1所述的装置,其中所述状态空间还配置成存储来自于所述指令译码单元的状态指针,其中所述状态指针指示用于生成操作的第一状态向量在 所述状态空间中的位置和用于所述更新操作的第一更新状态向量在所述状态空间中的位置。Clause A7. The apparatus of Clause A1, wherein the state space is further configured to store a state pointer from the instruction decode unit, wherein the state pointer indicates that a first state vector for a generate operation is in the A location in state space and a location in said state space of a first updated state vector for said update operation.

条款A8、根据条款A1所述的装置,其中所述状态空间包括多个空间区段,并且在所述流水操作中,所述多个空间区段根据要执行的生成操作和更新操作而可变地操作于读取空间区段或写入空间区段,其中所述读取空间区段和写入空间区段在所述状态空间中具有预定的地址间隔,以便支持所述生成操作和更新操作以流水方式执行。Clause A8. The apparatus of clause A1, wherein the state space includes a plurality of space segments, and in the pipelining, the plurality of space segments is variable according to the generation and update operations to be performed operate on a read space segment or a write space segment, wherein the read space segment and the write space segment have predetermined address intervals in the state space to support the generate operation and the update operation Executed in a streamlined manner.

条款A9、根据条款A1所述的装置,其中所述状态空间包括N个连续分布的读取空间区段和N个连续分布的写入空间区段,并且所述N个读取空间区段和所述N个写入空间区段在流水操作中形成对应关系,其中N是大于或等于2的正整数,并且在所述流水操作过程中,所述运算单元配置成根据预生成的随机数的数目循环执行以下的操作,其中i=1,…N:Clause A9. The apparatus of clause A1, wherein the state space comprises N consecutively distributed read space segments and N continuously distributed write space segments, and the N read space segments and The N write space segments form a corresponding relationship in the pipeline operation, wherein N is a positive integer greater than or equal to 2, and during the pipeline operation, the operation unit is configured to The number loop performs the following operations, where i=1,...N:

在所述生成操作中,从第i读取空间区段中读取多个状态向量,以生成对应的第i多个随机数;以及In the generating operation, read a plurality of state vectors from the i-th read space section to generate corresponding i-th random numbers; and

在所述更新操作中,根据所述第i读取空间区段中的所述多个状态向量来生成用于更新状态空间的多个状态更新向量,并且将所述多个状态更新向量写入所述第i写入空间区段。In the update operation, a plurality of state update vectors for updating the state space are generated according to the plurality of state vectors in the i-th read space segment, and the plurality of state update vectors are written into The i-th write space segment.

条款A10、根据条款A1所述的装置,其中在所述状态空间的初始化过程中,所述状态空间划分成大小相同的第一状态子空间和第二状态子空间,所述运算单元配置成:Clause A10. The apparatus of clause A1, wherein during initialization of the state space, the state space is divided into a first state subspace and a second state subspace of the same size, the arithmetic unit is configured to:

利用存储于所述第一状态子空间中的状态向量来执行针对所述第二状态子空间的更新操作,以生成用于第二状态子空间的所有状态向量。An update operation for the second state subspace is performed using state vectors stored in the first state subspace to generate all state vectors for the second state subspace.

条款A11、根据条款A10所述的装置,其中在生成第二状态子空间的所有状态向量中,所述运算单元还配置成:Clause A11. The apparatus of clause A10, wherein in generating all state vectors of the second state subspace, the arithmetic unit is further configured to:

顺序地执行多条微指令,以生成用于更新第二状态子空间的所有状态向量,其中每条微指令的执行生成对应数目的状态向量。A plurality of microinstructions are executed sequentially to generate all state vectors for updating the second state subspace, wherein the execution of each microinstruction generates a corresponding number of state vectors.

条款A12、根据条款A1-A11的任意一项所述的装置,其中:Clause A12. The device of any one of clauses A1-A11, wherein:

在单个种子下,所述运算单元配置成利用单个种子生成的状态向量来执行所述生成操作以生成所述随机数,并且执行所述更新操作以更新状态空间的相关状态向量;或者Under a single seed, the arithmetic unit is configured to perform the generation operation to generate the random number using a state vector generated by a single seed, and perform the update operation to update an associated state vector of the state space; or

在多个种子下,每个种子具有其关联的状态空间,并且所述运算单元配置成分别利用多个种子中的各个种子生成的状态向量来执行与各个种子关联的生成操作,以生成与各个种子关联的所述随机数,并且执行与各个种子关联的更新操作以更新与各个种子关联的状态空间的相关状态向量。Under a plurality of seeds, each seed has its associated state space, and the operation unit is configured to use the state vector generated by each seed in the plurality of seeds to perform the generation operation associated with each seed, so as to generate the state vector associated with each seed The random numbers associated with the seeds, and an update operation associated with each seed is performed to update the associated state vector of the state space associated with each seed.

条款A13、根据条款A12所述的装置,其中在单个种子下,所述运算单元配置成:Clause A13. The apparatus of Clause A12, wherein under a single seed, the arithmetic unit is configured to:

根据多条微指令来连续地交替执行生成所述随机数的生成操作和用于更新状态空间的更新操作,直至生成预定数目的随机数,Continuously and alternately performing the generation operation for generating the random number and the update operation for updating the state space according to a plurality of microinstructions until a predetermined number of random numbers are generated,

其中每次生成操作生成部分数目的随机数并且每次更新操作更新所述状态空间中对应数目的状态向量。Each generating operation generates a partial number of random numbers and each updating operation updates a corresponding number of state vectors in the state space.

条款A14、根据条款A12所述的装置,其中多个种子包括第一种子和第二种子, 其中所述存储器设置有与第一种子和第二种子各自关联的所述状态空间,并且在执行用于生成随机数的流水操作中,所述运算单元配置成根据所述随机数指令来循环执行如下操作,直至生成预定数目的随机数:Clause A14. The apparatus of Clause A12, wherein the plurality of seeds comprises a first seed and a second seed, wherein the memory is provided with the state space associated with each of the first seed and the second seed, and is executed with In the pipeline operation for generating random numbers, the operation unit is configured to perform the following operations cyclically according to the random number instruction until a predetermined number of random numbers are generated:

利用所述第一种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量;以及generating partial random numbers using the state space associated with the first seed, and updating a corresponding number of state vectors; and

利用所述第二种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。A state space associated with the second seed is used to generate partial random numbers, and a corresponding number of state vectors are updated.

条款A15、一种集成电路芯片,包括根据条款A1-A14的任意一项所述的装置。Clause A15. An integrated circuit chip comprising the device of any one of clauses A1-A14.

条款A16、一种板卡,包括根据条款A15所述的集成电路芯片。Clause A16. A board comprising the integrated circuit chip according to Clause A15.

条款A17、一种电子设备,包括根据条款A16所述的集成电路芯片。Clause A17. An electronic device comprising the integrated circuit chip according to Clause A16.

条款A18、一种用于生成随机数的方法,包括:Clause A18. A method for generating random numbers, comprising:

接收随机数指令并且对所述随机数指令进行译码;receiving random number instructions and decoding the random number instructions;

根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受对所述状态空间的状态向量更新;以及setting a state space based on the decoded random number instruction, wherein the state space is configured to store state vectors used to generate the random number and to accept state vector updates to the state space; and

根据所述译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量,Perform a random number generation operation based on a single seed or a plurality of seeds according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes a generation operation and an update performed in a pipelined manner operation, wherein the generate operation is used to generate random numbers and the update operation is used to update the state vector,

其中所述状态空间的大小设置成:Wherein the size of the state space is set as:

在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者Under a single seed, the generation operation and the update operation are supported to be performed in a pipelined manner; or

在多个种子下,支持以流水方式执行各个种子的随机数生成操作。Under multiple seeds, the random number generation operation of each seed is supported in a pipelined manner.

条款A19、根据条款A18所述的方法,其中所述随机数指令包括以下中的一项或多项:生成随机数的数目、状态空间的大小和地址、用于生成随机数的一个或多个种子信息、用于拼接随机数的拼接参数和输出随机数的地址。Clause A19. The method of clause A18, wherein the random number instruction comprises one or more of: the number of random numbers to generate, the size and address of the state space, one or more Seed information, splicing parameters for splicing random numbers and address of outputting random numbers.

条款A20、根据条款A18所述的方法,其中所述随机数指令是单个指令并且经解析后得到用于执行流水操作的多个微指令,所述方法还包括:Clause A20. The method of Clause A18, wherein the random number instruction is a single instruction and is parsed to obtain a plurality of microinstructions for performing pipelining, the method further comprising:

根据所述微指令,以循环移位的方式沿所述状态空间来执行生成随机数的生成操作和更新所述状态空间的更新操作。According to the microinstruction, a generating operation for generating a random number and an updating operation for updating the state space are performed along the state space in a circular shift manner.

条款A21、根据条款A20所述的方法,其中所述微指令包括用于所述生成操作的生成微指令和用于所述更新操作的更新微指令,并且所述生成微指令和更新微指令与所述生成操作和更新操作所涉及的状态空间位置相关,并且所述方法包括以下面操作之一来生成部分数目的随机数和更新部分数目的状态向量:Clause A21. The method of clause A20, wherein said microinstructions comprise a generate microinstruction for said generate operation and an update microinstruction for said update operation, and said generate microinstruction and update microinstruction are related to The generating operation is related to the state space position involved in the updating operation, and the method includes generating a partial number of random numbers and updating a partial number of state vectors by one of the following operations:

根据一条生成微指令来生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量;或者generating a partial number of random numbers according to a generate uop and updating a partial number of state vectors according to an update uop; or

根据一个生成微指令来生成部分数目的随机数,并且根据多条更新微指令来分别更新部分数目的状态向量;或者generating a partial number of random numbers according to a generating microinstruction, and updating a partial number of state vectors respectively according to a plurality of updating microinstructions; or

根据多条生成微指令来分别生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量。A partial number of random numbers is respectively generated according to a plurality of generation microinstructions, and a partial number of state vectors is updated according to an update microinstruction.

条款A22、根据条款A20所述的方法,其中每个所述微指令包括指示针对状态空间的读取操作或写入操作的地址范围项,并且对于地址范围项存在地址交叠的两条连续微指令,所述方法还包括:Clause A22. The method of clause A20, wherein each of said microinstructions includes an address range entry indicating a read operation or a write operation to state space, and there are two consecutive microinstructions with overlapping addresses for the address range entry instructions, the method further comprising:

仅在执行完其中一条微指令的读取操作或写入操作后,才执行下一条微指令的读取操作或写入操作。Only after the read or write operation of one microinstruction is executed, the read or write operation of the next microinstruction is executed.

条款A23、根据条款A18所述的方法,其中所述状态空间的大小由软件来配置,以便使得在单个种子下的所述生成操作和更新操作以流水方式执行,并且使得在多个种子下的随机数生成操作以流水方式执行。Clause A23. The method of clause A18, wherein the size of the state space is configured by software such that the generation and update operations under a single seed are performed in a pipelined manner, and that the Random number generation operations are performed in a pipelined manner.

条款A24、根据条款A18所述的方法,其中所述状态空间还配置成存储状态指针,其中所述状态指针指示用于生成操作的第一状态向量在所述状态空间中的位置和用于所述更新操作的第一更新状态向量在所述状态空间中的位置。Clause A24. The method of Clause A18, wherein the state space is further configured to store a state pointer, wherein the state pointer indicates a location in the state space of a first state vector for a generate operation and a location in the state space for the The position of the first update state vector of the update operation in the state space.

条款A25、根据条款A18所述的方法,其中所述状态空间包括多个空间区段,并且在所述流水操作中,所述多个空间区段根据要执行的生成操作和更新操作而可变地操作于读取空间区段或写入空间区段,其中所述读取空间区段和写入空间区段在所述状态空间中具有预定的地址间隔,以便支持所述生成操作和更新操作以流水方式执行。Clause A25. The method of clause A18, wherein the state space comprises a plurality of space segments, and in the pipelining, the plurality of space segments is variable according to the generation and update operations to be performed operate on a read space segment or a write space segment, wherein the read space segment and the write space segment have predetermined address intervals in the state space to support the generate operation and the update operation Executed in a streamlined manner.

条款A26、根据条款A18所述的方法,其中所述状态空间包括N个连续分布的读取空间区段和N个连续分布的写入空间区段,并且所述N个读取空间区段和所述N个写入空间区段在流水操作中形成对应关系,其中N是大于或等于2的正整数,并且在所述流水操作过程中,所述方法根据预生成的随机数的数目循环执行以下的操作,其中i=1,…N:Clause A26. The method of clause A18, wherein the state space comprises N consecutively distributed read space segments and N continuously distributed write space segments, and the N read space segments and The N write space segments form a corresponding relationship in the pipeline operation, wherein N is a positive integer greater than or equal to 2, and during the pipeline operation, the method is executed cyclically according to the number of pre-generated random numbers The following operations, where i=1,...N:

在所述生成操作中,从第i读取空间区段中读取多个状态向量,以生成对应的第i多个随机数;以及In the generating operation, read a plurality of state vectors from the i-th read space section to generate corresponding i-th random numbers; and

在所述更新操作中,根据所述第i读取空间区段中的所述多个状态向量来生成用于更新状态空间的多个状态更新向量,并且将所述多个状态更新向量写入所述第i写入空间区段。In the update operation, a plurality of state update vectors for updating the state space are generated according to the plurality of state vectors in the i-th read space segment, and the plurality of state update vectors are written into The i-th write space segment.

条款A27、根据条款A18所述的方法,其中在所述状态空间的初始化过程中,所述状态空间划分成大小相同的第一状态子空间和第二状态子空间,所述方法还包括:Clause A27. The method of clause A18, wherein during initialization of the state space, the state space is divided into a first state subspace and a second state subspace of equal size, the method further comprising:

利用存储于所述第一状态子空间中的状态向量来执行针对所述第二状态子空间的更新操作,以生成用于第二状态子空间的所有状态向量。An update operation for the second state subspace is performed using state vectors stored in the first state subspace to generate all state vectors for the second state subspace.

条款A28、根据条款A27所述的方法,其中在生成第二状态子空间的所有状态向量中,所述方法还包括:Clause A28. The method of clause A27, wherein in generating all state vectors of the second state subspace, the method further comprising:

顺序地执行多条微指令,以生成用于更新第二状态子空间的所有状态向量,其中每条微指令的执行生成对应数目的状态向量。A plurality of microinstructions are executed sequentially to generate all state vectors for updating the second state subspace, wherein the execution of each microinstruction generates a corresponding number of state vectors.

条款A29、根据条款A18-A28的任意一项所述的方法,其中:Clause A29. The method of any one of clauses A18-A28, wherein:

在单个种子下,利用单个种子生成的状态向量来执行所述生成操作以生成所述随机数,并且执行所述更新操作以更新状态空间的相关状态向量;或者Under a single seed, performing said generate operation to generate said random number using a state vector generated by a single seed, and performing said update operation to update an associated state vector of a state space; or

在多个种子下,每个种子具有其关联的状态空间,并且所述方法分别利用多个种子中的各个种子生成的状态向量来执行与各个种子关联的生成操作,以生成与各个种子关联的所述随机数,并且执行与各个种子关联的更新操作以更新与各个种子关联的状态空间的相关状态向量。Under multiple seeds, each seed has its associated state space, and the method respectively utilizes the state vectors generated by each of the multiple seeds to perform the generation operation associated with each seed to generate the state vector associated with each seed The random number, and an update operation associated with each seed is performed to update the associated state vector of the state space associated with each seed.

条款A30、根据条款A29所述的方法,其中在单个种子下,所述方法还包括:Clause A30. The method of Clause A29, wherein under a single seed, the method further comprises:

根据多条微指令来连续地交替执行生成所述随机数的生成操作和用于更新状态 空间的更新操作,直至生成预定数目的随机数,Continuously alternately perform the generation operation for generating the random number and the update operation for updating the state space according to a plurality of microinstructions until a predetermined number of random numbers are generated,

其中每次生成操作生成部分数目的随机数并且每次更新操作更新所述状态空间中对应数目的状态向量。Each generating operation generates a partial number of random numbers and each updating operation updates a corresponding number of state vectors in the state space.

条款A31、根据条款A29所述的方法,其中多个种子包括第一种子和第二种子,其中所述方法包括设置有与第一种子和第二种子各自关联的所述状态空间,并且在执行用于生成随机数的流水操作中,所述方法包括根据所述随机数指令来循环执行如下操作,直至生成预定数目的随机数:Clause A31. The method of Clause A29, wherein the plurality of seeds comprises a first seed and a second seed, wherein the method comprises providing the state space associated with each of the first seed and the second seed, and performing In the pipeline operation for generating random numbers, the method includes performing the following operations in a loop according to the random number instruction until a predetermined number of random numbers are generated:

利用所述第一种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量;以及generating partial random numbers using the state space associated with the first seed, and updating a corresponding number of state vectors; and

利用所述第二种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。A state space associated with the second seed is used to generate partial random numbers, and a corresponding number of state vectors are updated.

应当理解,本披露的权利要求、说明书及附图中的术语“第一”、“第二”、“第三”和“第四”等是用于区别不同对象,而不是用于描述特定顺序。本披露的说明书和权利要求书中使用的术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that the terms "first", "second", "third" and "fourth" in the claims, specification and drawings of the present disclosure are used to distinguish different objects, rather than to describe a specific order . The terms "comprising" and "comprises" used in the specification and claims of this disclosure indicate the presence of described features, integers, steps, operations, elements and/or components, but do not exclude one or more other features, integers , steps, operations, elements, components, and/or the presence or addition of collections thereof.

还应当理解,在此本披露说明书中所使用的术语仅仅是出于描述特定实施例的目的,而并不意在限定本披露。如在本披露说明书和权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。还应当进一步理解,在本披露说明书和权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should also be understood that the terminology used in this disclosure description is for the purpose of describing specific embodiments only, and is not intended to limit the present disclosure. As used in this disclosure and the claims, the singular forms "a", "an" and "the" are intended to include plural referents unless the context clearly dictates otherwise. It should also be further understood that the term "and/or" used in the present disclosure and the claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

如在本说明书和权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and claims, the term "if" may be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, to mean "once determined" or "in response to the determination" or "once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.

虽然本文已经示出和描述了本披露的多个实施例,但对于本领域技术人员显而易见的是,这样的实施例只是以示例的方式来提供。本领域技术人员可以在不偏离本披露思想和精神的情况下想到许多更改、改变和替代的方式。应当理解的是在实践本披露的过程中,可以采用对本文所描述的本披露实施例的各种替代方案。所附权利要求书旨在限定本披露的保护范围,并因此覆盖这些权利要求范围内的等同或替代方案。While various embodiments of the present disclosure have been shown and described herein, it would be obvious to those skilled in the art that such embodiments are provided by way of example only. Many modifications, changes and substitutions may occur to those skilled in the art without departing from the idea and spirit of the present disclosure. It should be understood that various alternatives to the embodiments of the disclosure described herein may be employed in practicing the disclosure. It is intended that the appended claims define the scope of protection of the present disclosure and thus cover equivalents or alternatives within the scope of these claims.

Claims (31)

Translated fromChinese
一种用于生成随机数的装置,包括:A device for generating random numbers, comprising:指令译码单元,其配置成接收随机数指令并且对所述随机数指令进行译码;an instruction decoding unit configured to receive a random number instruction and decode the random number instruction;运算单元,其配置成根据所述译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量;以及an arithmetic unit configured to perform a random number generation operation based on a single seed or a plurality of seeds according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes performing a generate operation and an update operation, wherein the generate operation is used to generate a random number and the update operation is used to update a state vector; and存储器,其配置成根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受来自运算单元对所述状态空间的状态向量更新,a memory configured to set up a state space according to the decoded random number instruction, wherein the state space is configured to store a state vector used to generate the random number and accept a state of the state space from an arithmetic unit vector update,其中所述状态空间的大小设置成:Wherein the size of the state space is set as:在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者Under a single seed, the generation operation and the update operation are supported to be performed in a pipelined manner; or在多个种子下,支持以流水方式执行各个种子的随机数生成操作。Under multiple seeds, the random number generation operation of each seed is supported in a pipelined manner.根据权利要求1所述的装置,其中所述随机数指令包括以下中的一项或多项:生成随机数的数目、状态空间的大小和地址、用于生成随机数的一个或多个种子信息、用于拼接随机数的拼接参数和输出随机数的地址。The device according to claim 1, wherein the random number instruction includes one or more of the following: the number of generated random numbers, the size and address of the state space, and one or more seed information for generating random numbers , splicing parameters for splicing random numbers and the address of outputting random numbers.根据权利要求1所述的装置,其中所述随机数指令是单个指令并且经所述指令译码单元解析后得到用于执行流水操作的多条微指令,其中所述运算单元配置成:The device according to claim 1, wherein the random number instruction is a single instruction and is analyzed by the instruction decoding unit to obtain a plurality of microinstructions for performing pipeline operations, wherein the operation unit is configured to:根据所述微指令,以循环移位的方式沿所述状态空间来执行生成随机数的生成操作和更新所述状态空间的更新操作。According to the microinstruction, a generating operation for generating a random number and an updating operation for updating the state space are performed along the state space in a circular shift manner.根据权利要求3所述的装置,其中所述微指令包括用于所述生成操作的生成微指令和用于所述更新操作的更新微指令,并且所述生成微指令和更新微指令与所述生成操作和更新操作所涉及的状态空间位置相关,并且所述运算单元配置成以下面操作之一来生成部分数目的随机数和更新部分数目的状态向量:The apparatus according to claim 3, wherein said microinstructions include a generate microinstruction for said generate operation and an update microinstruction for said update operation, and said generate microinstruction and update microinstruction are the same as said The state space positions involved in the generation operation and the update operation are related, and the operation unit is configured to generate a partial number of random numbers and update a partial number of state vectors with one of the following operations:根据一条生成微指令来生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量;或者generating a partial number of random numbers according to a generate uop and updating a partial number of state vectors according to an update uop; or根据一条生成微指令来生成部分数目的随机数,并且根据多条更新微指令来分别更新部分数目的状态向量;或者generating a partial number of random numbers according to a generating microinstruction, and updating a partial number of state vectors respectively according to a plurality of updating microinstructions; or根据多条生成微指令来分别生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量。A partial number of random numbers is respectively generated according to a plurality of generation microinstructions, and a partial number of state vectors is updated according to an update microinstruction.根据权利要求3所述的装置,其中每条所述微指令包括指示针对状态空间的读取操作或写入操作的地址范围项,并且对于地址范围项存在地址交叠的两条连续微指令,所述运算单元配置成:The apparatus according to claim 3, wherein each of said microinstructions includes an address range item indicating a read operation or a write operation for the state space, and there are two consecutive microinstructions with overlapping addresses for the address range item, The computing unit is configured to:仅在执行完其中一条微指令的读取操作或写入操作后,才执行下一条微指令的读取操作或写入操作。Only after the read or write operation of one microinstruction is executed, the read or write operation of the next microinstruction is executed.根据权利要求1所述的装置,其中所述状态空间的大小由软件来配置,以便使得在单个种子下的所述生成操作和更新操作以流水方式执行,并且使得在多个种子下的随机数生成操作以流水方式执行。The apparatus of claim 1, wherein the size of the state space is configured by software so that the generation operation and the update operation under a single seed are performed in a pipelined manner, and the random number under multiple seeds Build operations are performed in a pipelined fashion.根据权利要求1所述的装置,其中所述状态空间还配置成存储来自于所述指令译码单元的状态指针,其中所述状态指针指示用于生成操作的第一状态向量在所述 状态空间中的位置和用于更新操作的第一更新状态向量在所述状态空间中的位置。The apparatus of claim 1, wherein the state space is further configured to store a state pointer from the instruction decode unit, wherein the state pointer indicates that a first state vector for a generate operation is in the state space The position in and the position in the state space of the first update state vector for the update operation.根据权利要求1所述的装置,其中所述状态空间包括多个空间区段,并且在所述流水操作中,所述多个空间区段根据要执行的生成操作和更新操作而可变地操作于读取空间区段或写入空间区段,其中所述读取空间区段和写入空间区段在所述状态空间中具有预定的地址间隔,以便支持所述生成操作和更新操作以流水方式执行。The apparatus according to claim 1, wherein the state space includes a plurality of space segments, and in the pipeline operation, the plurality of space segments are variably operated according to generation operations and update operations to be performed for a read space segment or a write space segment, wherein the read space segment and the write space segment have predetermined address intervals in the state space in order to support the generation and update operations in a pipeline way to execute.根据权利要求1所述的装置,其中所述状态空间包括N个连续分布的读取空间区段和N个连续分布的写入空间区段,并且所述N个读取空间区段和所述N个写入空间区段在流水操作中形成对应关系,其中N是大于或等于2的正整数,并且在所述流水操作过程中,所述运算单元配置成根据预生成的随机数的数目循环执行以下的操作,其中i=1,…N:The apparatus according to claim 1, wherein said state space comprises N consecutively distributed read space segments and N continuously distributed write space segments, and said N read space segments and said The N write space segments form a corresponding relationship in the pipeline operation, wherein N is a positive integer greater than or equal to 2, and during the pipeline operation, the operation unit is configured to cycle according to the number of pre-generated random numbers Perform the following operations, where i=1,...N:在所述生成操作中,从第i读取空间区段中读取多个状态向量,以生成对应的第i多个随机数;以及In the generating operation, read a plurality of state vectors from the i-th read space section to generate corresponding i-th random numbers; and在所述更新操作中,根据所述第i读取空间区段中的所述多个状态向量来生成用于更新状态空间的多个状态更新向量,并且将所述多个状态更新向量写入所述第i写入空间区段。In the update operation, a plurality of state update vectors for updating the state space are generated according to the plurality of state vectors in the i-th read space segment, and the plurality of state update vectors are written into The i-th write space segment.根据权利要求1所述的装置,其中在所述状态空间的初始化过程中,所述状态空间划分成大小相同的第一状态子空间和第二状态子空间,所述运算单元配置成:The device according to claim 1, wherein in the initialization process of the state space, the state space is divided into a first state subspace and a second state subspace having the same size, and the operation unit is configured to:利用存储于所述第一状态子空间中的状态向量来执行针对所述第二状态子空间的更新操作,以生成用于第二状态子空间的所有状态向量。An update operation for the second state subspace is performed using state vectors stored in the first state subspace to generate all state vectors for the second state subspace.根据权利要求10所述的装置,其中在生成第二状态子空间的所有状态向量中,所述运算单元还配置成:The device according to claim 10, wherein in generating all state vectors of the second state subspace, the operation unit is further configured to:顺序地执行多条微指令,以生成用于更新第二状态子空间的所有状态向量,其中每条微指令的执行生成对应数目的状态向量。A plurality of microinstructions are executed sequentially to generate all state vectors for updating the second state subspace, wherein the execution of each microinstruction generates a corresponding number of state vectors.根据权利要求1-11的任意一项所述的装置,其中:The apparatus according to any one of claims 1-11, wherein:在单个种子下,所述运算单元配置成利用单个种子生成的状态向量来执行所述生成操作以生成所述随机数,并且执行所述更新操作以更新状态空间的相关状态向量;或者Under a single seed, the arithmetic unit is configured to perform the generation operation to generate the random number using a state vector generated by a single seed, and perform the update operation to update an associated state vector of the state space; or在多个种子下,每个种子具有其关联的状态空间,并且所述运算单元配置成分别利用多个种子中的各个种子生成的状态向量来执行与各个种子关联的生成操作,以生成与各个种子关联的所述随机数,并且执行与各个种子关联的更新操作以更新与各个种子关联的状态空间的相关状态向量。Under a plurality of seeds, each seed has its associated state space, and the operation unit is configured to use the state vector generated by each seed in the plurality of seeds to perform the generation operation associated with each seed, so as to generate the state vector associated with each seed The random numbers associated with the seeds, and an update operation associated with each seed is performed to update the associated state vector of the state space associated with each seed.根据权利要求12所述的装置,其中在单个种子下,所述运算单元配置成:The apparatus according to claim 12, wherein under a single seed, the operation unit is configured to:根据多条微指令来连续地交替执行生成所述随机数的生成操作和用于更新状态空间的更新操作,直至生成预定数目的随机数,Continuously and alternately performing the generation operation for generating the random number and the update operation for updating the state space according to a plurality of microinstructions until a predetermined number of random numbers are generated,其中每次生成操作生成部分数目的随机数并且每次更新操作更新所述状态空间中对应数目的状态向量。Each generating operation generates a partial number of random numbers and each updating operation updates a corresponding number of state vectors in the state space.根据权利要求12所述的装置,其中多个种子包括第一种子和第二种子,其中所述存储器设置有与第一种子和第二种子各自关联的所述状态空间,并且在执行用于生成随机数的流水操作中,所述运算单元配置成根据所述随机数指令来循环执行如下操作,直至生成预定数目的随机数:The apparatus of claim 12, wherein the plurality of seeds comprises a first seed and a second seed, wherein the memory is provided with the state space associated with each of the first seed and the second seed, and is used to generate In the pipeline operation of random numbers, the operation unit is configured to perform the following operations cyclically according to the random number instructions until a predetermined number of random numbers are generated:利用所述第一种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量;以及generating partial random numbers using the state space associated with the first seed, and updating a corresponding number of state vectors; and利用所述第二种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。A state space associated with the second seed is used to generate partial random numbers, and a corresponding number of state vectors are updated.一种集成电路芯片,包括根据权利要求1-14的任意一项所述的装置。An integrated circuit chip comprising the device according to any one of claims 1-14.一种板卡,包括根据权利要求15所述的集成电路芯片。A board comprising the integrated circuit chip according to claim 15.一种电子设备,包括根据权利要求16所述的集成电路芯片。An electronic device comprising an integrated circuit chip according to claim 16.一种用于生成随机数的方法,包括:A method for generating random numbers comprising:接收随机数指令并且对所述随机数指令进行译码;receiving random number instructions and decoding the random number instructions;根据译码后的所述随机数指令来设置状态空间,其中所述状态空间配置成存储用于生成所述随机数的状态向量并且接受对所述状态空间的状态向量更新;以及setting a state space based on the decoded random number instruction, wherein the state space is configured to store state vectors used to generate the random number and to accept state vector updates to the state space; and根据所述译码后的随机数指令来执行基于单个种子或多个种子的随机数生成操作,其中针对于每个所述种子,所述随机数生成操作包括以流水方式执行的生成操作和更新操作,其中所述生成操作用于生成随机数并且所述更新操作用于更新状态向量,Perform a random number generation operation based on a single seed or a plurality of seeds according to the decoded random number instruction, wherein for each of the seeds, the random number generation operation includes a generation operation and an update performed in a pipelined manner operation, wherein the generate operation is used to generate random numbers and the update operation is used to update the state vector,其中所述状态空间的大小设置成:Wherein the size of the state space is set as:在单个种子下,支持以流水方式执行所述生成操作和更新操作;或者Under a single seed, the generation operation and the update operation are supported to be performed in a pipelined manner; or在多个种子下,支持以流水方式执行各个种子的随机数生成操作。Under multiple seeds, the random number generation operation of each seed is supported in a pipelined manner.根据权利要求18所述的方法,其中所述随机数指令包括以下中的一项或多项:生成随机数的数目、状态空间的大小和地址、用于生成随机数的一个或多个种子信息、用于拼接随机数的拼接参数和输出随机数的地址。The method according to claim 18, wherein the random number instruction includes one or more of the following: the number of generated random numbers, the size and address of the state space, and one or more seed information for generating random numbers , splicing parameters for splicing random numbers and the address of outputting random numbers.根据权利要求18所述的方法,其中所述随机数指令是单个指令并且经解析后得到用于执行流水操作的多条微指令,所述方法还包括:The method according to claim 18, wherein the random number instruction is a single instruction and is analyzed to obtain a plurality of microinstructions for performing pipeline operations, the method also includes:根据所述微指令,以循环移位的方式沿所述状态空间来执行生成随机数的生成操作和更新所述状态空间的更新操作。According to the microinstruction, a generating operation for generating a random number and an updating operation for updating the state space are performed along the state space in a circular shift manner.根据权利要求20所述的方法,其中所述微指令包括用于所述生成操作的生成微指令和用于所述更新操作的更新微指令,并且所述生成微指令和更新微指令与所述生成操作和更新操作所涉及的状态空间位置相关,并且所述方法包括以下面操作之一来生成部分数目的随机数和更新部分数目的状态向量:The method of claim 20, wherein said microinstructions include a generate microinstruction for said generate operation and an update microinstruction for said update operation, and said generate microinstruction and update microinstruction are identical to said The state space positions involved in the generation operation and the update operation are related, and the method includes generating a partial number of random numbers and updating a partial number of state vectors by one of the following operations:根据一条生成微指令来生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量;或者generating a partial number of random numbers according to a generate uop and updating a partial number of state vectors according to an update uop; or根据一条生成微指令来生成部分数目的随机数,并且根据多条更新微指令来更新部分数目的状态向量;或者generating a partial number of random numbers according to a generate microinstruction, and updating a partial number of state vectors according to a plurality of update microinstructions; or根据多条生成微指令来分别生成部分数目的随机数,并且根据一条更新微指令来更新部分数目的状态向量。A partial number of random numbers is respectively generated according to a plurality of generation microinstructions, and a partial number of state vectors is updated according to an update microinstruction.根据权利要求20所述的方法,其中每条所述微指令包括指示针对状态空间的读取操作或写入操作的地址范围项,并且对于地址范围项存在地址交叠的两条连续微指令,所述方法还包括:The method according to claim 20, wherein each of the microinstructions includes an address range entry indicating a read operation or a write operation for the state space, and there are two consecutive microinstructions with overlapping addresses for the address range entry, The method also includes:仅在执行完其中一条微指令的读取操作或写入操作后,才执行下一条微指令的读取操作或写入操作。Only after the read or write operation of one microinstruction is executed, the read or write operation of the next microinstruction is executed.根据权利要求18所述的方法,其中所述状态空间的大小由软件来配置,以 便使得在单个种子下的所述生成操作和更新操作以流水方式执行,并且使得在多个种子下的随机数生成操作以流水方式执行。The method of claim 18, wherein the size of the state space is configured by software so that the generation and update operations under a single seed are performed in a pipelined manner, and the random number under multiple seeds Build operations are performed in a pipelined fashion.根据权利要求18所述的方法,其中所述状态空间还配置成存储状态指针,其中所述状态指针指示用于生成操作的第一状态向量在所述状态空间中的位置和用于更新操作的第一更新状态向量在所述状态空间中的位置。The method of claim 18, wherein the state space is further configured to store a state pointer, wherein the state pointer indicates the location in the state space of a first state vector for a generate operation and a first state vector for an update operation. The location of the state vector in the state space is first updated.根据权利要求18所述的方法,其中所述状态空间包括多个空间区段,并且在所述流水操作中,所述多个空间区段根据要执行的生成操作和更新操作而可变地操作于读取空间区段或写入空间区段,其中所述读取空间区段和写入空间区段在所述状态空间中具有预定的地址间隔,以便支持所述生成操作和更新操作以流水方式执行。The method of claim 18, wherein the state space includes a plurality of space segments, and in the pipelining, the plurality of space segments are variably operated according to generation operations and update operations to be performed for a read space segment or a write space segment, wherein the read space segment and the write space segment have predetermined address intervals in the state space in order to support the generation and update operations in a pipeline way to execute.根据权利要求18所述的方法,其中所述状态空间包括N个连续分布的读取空间区段和N个连续分布的写入空间区段,并且所述N个读取空间区段和所述N个写入空间区段在流水操作中形成对应关系,其中N是大于或等于2的正整数,并且在所述流水操作过程中,所述方法根据预生成的随机数的数目循环执行以下的操作,其中i=1,…N:The method according to claim 18, wherein said state space comprises N consecutively distributed read space segments and N continuously distributed write space segments, and said N read space segments and said The N write space segments form a corresponding relationship in the pipeline operation, where N is a positive integer greater than or equal to 2, and during the pipeline operation, the method performs the following cyclically according to the number of pre-generated random numbers Operation, where i=1,...N:在所述生成操作中,从第i读取空间区段中读取多个状态向量,以生成对应的第i多个随机数;以及In the generating operation, read a plurality of state vectors from the i-th read space section to generate corresponding i-th random numbers; and在所述更新操作中,根据所述第i读取空间区段中的所述多个状态向量来生成用于更新状态空间的多个状态更新向量,并且将所述多个状态更新向量写入所述第i写入空间区段。In the update operation, a plurality of state update vectors for updating the state space are generated according to the plurality of state vectors in the i-th read space segment, and the plurality of state update vectors are written into The i-th write space segment.根据权利要求18所述的方法,其中在所述状态空间的初始化过程中,所述状态空间划分成大小相同的第一状态子空间和第二状态子空间,所述方法还包括:The method according to claim 18, wherein during the initialization of the state space, the state space is divided into a first state subspace and a second state subspace of the same size, the method further comprising:利用存储于所述第一状态子空间中的状态向量来执行针对所述第二状态子空间的更新操作,以生成用于第二状态子空间的所有状态向量。An update operation for the second state subspace is performed using state vectors stored in the first state subspace to generate all state vectors for the second state subspace.根据权利要求27所述的方法,其中在生成第二状态子空间的所有状态向量中,所述方法还包括:The method of claim 27, wherein in generating all state vectors of the second state subspace, the method further comprises:顺序地执行多条微指令,以生成用于更新第二状态子空间的所有状态向量,其中每条微指令的执行生成对应数目的状态向量。A plurality of microinstructions are executed sequentially to generate all state vectors for updating the second state subspace, wherein the execution of each microinstruction generates a corresponding number of state vectors.根据权利要求18-28的任意一项所述的方法,其中:A method according to any one of claims 18-28, wherein:在单个种子下,利用单个种子生成的状态向量来执行所述生成操作以生成所述随机数,并且执行所述更新操作以更新状态空间的相关状态向量;或者Under a single seed, performing said generate operation to generate said random number using a state vector generated by a single seed, and performing said update operation to update an associated state vector of a state space; or在多个种子下,每个种子具有其关联的状态空间,并且所述方法分别利用多个种子中的各个种子生成的状态向量来执行与各个种子关联的生成操作,以生成与各个种子关联的所述随机数,并且执行与各个种子关联的更新操作以更新与各个种子关联的状态空间的相关状态向量。Under multiple seeds, each seed has its associated state space, and the method respectively utilizes the state vectors generated by each of the multiple seeds to perform the generation operation associated with each seed to generate the state vector associated with each seed The random number, and an update operation associated with each seed is performed to update the associated state vector of the state space associated with each seed.根据权利要求29所述的方法,其中在单个种子下,所述方法还包括:The method of claim 29, wherein under a single seed, the method further comprises:根据多条微指令来连续地交替执行生成所述随机数的生成操作和用于更新状态空间的更新操作,直至生成预定数目的随机数,Continuously and alternately performing the generation operation for generating the random number and the update operation for updating the state space according to a plurality of microinstructions until a predetermined number of random numbers are generated,其中每次生成操作生成部分数目的随机数并且每次更新操作更新所述状态空间中对应数目的状态向量。Each generating operation generates a partial number of random numbers and each updating operation updates a corresponding number of state vectors in the state space.根据权利要求29所述的方法,其中多个种子包括第一种子和第二种子,其 中所述方法包括设置有与第一种子和第二种子各自关联的所述状态空间,并且在执行用于生成随机数的流水操作中,所述方法包括根据所述随机数指令来循环执行如下操作,直至生成预定数目的随机数:The method of claim 29, wherein the plurality of seeds comprises a first seed and a second seed, wherein the method includes providing the state space associated with each of the first seed and the second seed, and performing the In the pipeline operation for generating random numbers, the method includes cyclically performing the following operations according to the random number instruction until a predetermined number of random numbers are generated:利用所述第一种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量;以及generating partial random numbers using the state space associated with the first seed, and updating a corresponding number of state vectors; and利用所述第二种子关联的状态空间来生成部分随机数,并且更新对应数目的状态向量。A state space associated with the second seed is used to generate partial random numbers, and a corresponding number of state vectors are updated.
PCT/CN2022/0967252021-06-042022-06-02Method for generating random number, and related product thereofCeasedWO2022253287A1 (en)

Applications Claiming Priority (2)

Application NumberPriority DateFiling DateTitle
CN202110622813.4ACN115437603B (en)2021-06-042021-06-04Method for generating random numbers and related products
CN202110622813.42021-06-04

Publications (1)

Publication NumberPublication Date
WO2022253287A1true WO2022253287A1 (en)2022-12-08

Family

ID=84240366

Family Applications (1)

Application NumberTitlePriority DateFiling Date
PCT/CN2022/096725CeasedWO2022253287A1 (en)2021-06-042022-06-02Method for generating random number, and related product thereof

Country Status (2)

CountryLink
CN (1)CN115437603B (en)
WO (1)WO2022253287A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN113296736A (en)*2020-02-242021-08-24中科寒武纪科技股份有限公司Data processing method based on random number, random number generation method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
GB2465419A (en)*2008-11-202010-05-26Simba Hpc LtdPseudo random number generator architecture using pipelined processing blocks
CN105867878A (en)*2016-04-262016-08-17合肥工业大学High-speed parallel true random number generator
CN110058843A (en)*2019-03-272019-07-26阿里巴巴集团控股有限公司Generation method, device and the server of pseudo random number
CN111726220A (en)*2020-06-032020-09-29太原理工大学 Real-time and high-speed generation of quantum random codes based on chaos amplification of quantum noise

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US4434465A (en)*1981-04-131984-02-28Texas Instruments IncorporatedShared microinstruction states in control ROM addressing for a microcoded single chip microcomputer
AU632493B2 (en)*1988-05-031993-01-07Lg Electronics Inc.Microprocessor having external control store
US6314204B1 (en)*1998-11-032001-11-06Compaq Computer CorporationMultiple mode probability density estimation with application to multiple hypothesis tracking
US8244785B2 (en)*2007-04-302012-08-14Acei AbMethod of generating random numbers for a gaming system
US8255443B2 (en)*2008-06-032012-08-28International Business Machines CorporationExecution unit with inline pseudorandom number generator
US8533648B2 (en)*2010-05-132013-09-10Oracle International CorporationAutomatic clock-gating propagation technique
US8677027B2 (en)*2011-06-012014-03-18International Business Machines CorporationFibre channel input/output data routing system and method
CN105765600B (en)*2013-12-232018-12-18英特尔公司 Technologies and Architectures for Anonymizing User Data
US10614196B2 (en)*2014-08-142020-04-07Accenture Global Services LimitedSystem for automated analysis of clinical text for pharmacovigilance
CN107315565B (en)*2016-04-262020-08-07中科寒武纪科技股份有限公司Device and method for generating random vectors obeying certain distribution
US11243893B2 (en)*2018-05-112022-02-08Intel CorporationPreventing unauthorized access to encrypted memory
CN111353124A (en)*2018-12-202020-06-30上海寒武纪信息科技有限公司 Computing method, apparatus, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
GB2465419A (en)*2008-11-202010-05-26Simba Hpc LtdPseudo random number generator architecture using pipelined processing blocks
CN105867878A (en)*2016-04-262016-08-17合肥工业大学High-speed parallel true random number generator
CN110058843A (en)*2019-03-272019-07-26阿里巴巴集团控股有限公司Generation method, device and the server of pseudo random number
CN111726220A (en)*2020-06-032020-09-29太原理工大学 Real-time and high-speed generation of quantum random codes based on chaos amplification of quantum noise

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN113296736A (en)*2020-02-242021-08-24中科寒武纪科技股份有限公司Data processing method based on random number, random number generation method and device
CN113296736B (en)*2020-02-242025-01-24中科寒武纪科技股份有限公司 Data processing method based on random numbers, random number generation method and device

Also Published As

Publication numberPublication date
CN115437603B (en)2023-12-19
CN115437603A (en)2022-12-06

Similar Documents

PublicationPublication DateTitle
CN107315715B (en) An apparatus and method for performing matrix addition/subtraction operations
CN107315567B (en)Device and method for executing vector maximum and minimum operation
CN111381871A (en) Computing method, device and related products
CN107315568B (en) An apparatus for performing vector logic operations
CN111176608A (en) An apparatus and method for performing vector comparison operations
WO2022253287A1 (en)Method for generating random number, and related product thereof
CN111767995A (en) Computing method, device and related products
CN111258769A (en) Data transmission device and method
CN107315565B (en)Device and method for generating random vectors obeying certain distribution
CN112084023A (en) Data parallel processing method, electronic device and computer readable storage medium
CN111813449A (en) Computing method, device and related products
CN111381873A (en)Operation method, device and related product
CN107688466B (en)Arithmetic device and operation method thereof
CN111290789B (en)Operation method, operation device, computer equipment and storage medium
WO2022100345A1 (en)Processing method, processing apparatus, and related product
CN111382851A (en)Operation method, device and related product
CN111382850A (en)Operation method, device and related product
CN111401536A (en) Computing method, device and related products
CN111260045B (en)Decoder and atomic instruction analysis method
CN111400341B (en) Scalar search instruction processing method, device and related products
CN117667211A (en)Instruction synchronous control method, synchronous controller, processor, chip and board card
CN115878184A (en)Method, storage medium and device for moving multiple data based on one instruction
CN114489802A (en)Data processing device, data processing method and related product
CN114281302A (en)Random number generation device, method and related product
CN114489804A (en) Processing method, processing device and related products

Legal Events

DateCodeTitleDescription
121Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number:22815329

Country of ref document:EP

Kind code of ref document:A1

NENPNon-entry into the national phase

Ref country code:DE

122Ep: pct application non-entry in european phase

Ref document number:22815329

Country of ref document:EP

Kind code of ref document:A1


[8]ページ先頭

©2009-2025 Movatter.jp