Aiming at the problem that it is difficult to write Athread code under Sunway environment,an automatic Athread code generation tool that could convert the serial kernel into Athread code was designed and developed.Rust language was used for lexical and syntactic analysis.For different dimensions of arrays in Fortran language and C language,based on a three-tier pro-gram template,the main program called the master program and then the master program called the slave program,while popu-lar many-core optimization methods were applied.Experimental results show that the Athread code generated using the automatic generation tool has higher speedup than the OpenACC*accelerated program,especially for multiple kernels,the speedup can be about 15%,which verifies that the generation tool is valuable in practical application.