In this paper we provide solutions to two different (but related) design problems involving large-scale linear dynamical systems: 1) the optimal input/output structural design ensuring structural controllability/observability and incurring in the minimal cost under generic assumptions; and 2) the optimal structural control configuration design for decentralized control, i.e., the sparsest information pattern or the minimal communication between outputs and inputs, such that the closed-loop system has no structurally fixed modes and incurring in the minimal cost under the assumption that the communication devices have the same cost. We show that the proposed solution can be implemented efficiently, i.e., using an algorithm with polynomial time complexity in the number of the state variables. We illustrate the obtained results with an example.