Modern embedded systems such as autonomous vehicles and robotics increasingly rely on high-performance computing to satisfy real-time and data-intensive demands. Parallel code generation, which combines task- and data-parallelism, is essential to efficiently utilize heterogeneous platforms composed of CPUs and accelerators. This study proposes a model-based code-generation workflow that integrates Halide, a domain-specific language (DSL) for performance-optimized library generation, into a model-based parallelization framework. The proposed approach addresses the challenge of jointly optimizing task mapping, scheduling, and data partitioning in heterogeneous systems. For data- parallel tasks, we propose two integer linear programming (ILP) formulations: a function-based method assuming a function model of execution time and an interpolation-based method using sampled profiling data. This enables precise load balancing across the CPUs and accelerators. We performed experiments on random task graphs and practical Simulink models executed on both a PC and Jetson Orin Nano. Compared to the C code generated from Embedded Coder, our methods achieve over 650x on a PC and 50x on Jetson. The proposed ILP formulations outperformed other traditional task mapping and scheduling strategies. We also executed the tool under different heterogeneous computing APIs, including CUDA, OpenCL , and Vulkan, and conducted parallel performance tests to demonstrate its potential for portability.