Resource allocation in grid environment is a complex undertaking due to the heterogeneity and dynamic nature aroused by wide area sharing. To address the heterogeneous and computationally intractable problem of resource allocation optimization in grid, this paper presents an allocation algorithm for parallel tasks based on particle swarm optimization. The heterogeneity of grid user is tackled by introducing a universal utility function. And that computational intractability is solved using iterative searching of particle swarm. Experimental results show that the proposed algorithm is convergent and performs better than genetic algorithm.