Don Cheadle, at the Berlin Film Festival for the premiere of his Miles Davis biopic “Miles Ahead,” described the making of the film as “a herculean task,” adding that he had “to wear every hat because that was the only way to get the movie done.”

Cheadle directed, co-wrote, produced and stars in the film, which premieres Thursday in the Berlinale special gala showcase.

“Miles Ahead” focuses on a couple of days in the artist’s life in the late 1970s, a period in which David had “fallen into a creative chasm and the most interesting time in his life for me,” Cheadle said.

Much of the film’s story follows Davis’ attempts to recover an unheard session tape that has fallen into the hands of an unscrupulous record producer. Discussing the pic’s ’70s-style action, Cheadle said he actually saw himself in the project playing Miles Davis playing himself in a film. “I saw ‘Miles Ahead’ as a movie that he’d want to star in.”

The actor-director added that he “wanted to make a film that felt like Miles, not about Miles,” with a story that tumbled forwards and backwards in a freeform, impressionistic and improvisational style that reflected Davis’ music. “Miles said, ‘If you want to know about me, listen to my music.’”

For his feature film debut, Cheadle consulted a number of filmmakers with whom he’s worked in the past, including Carl Franklin, Steven Soderbergh and Paul Thomas Anderson. “They all pretty much said the same thing: Good luck … and don’t forget to do pushups and get enough sleep.”

Emayatzy Corinealdi, who plays Davis’ first wife, Frances Taylor, in the film, said it was “very helpful” having Cheadle “direct as Miles in almost the same way Miles directed his band, in a very freeform way. He allowed us to find our way there on our own.”

Cheadle said he discovered Corinealdi in Ava DuVernay’s “Middle of Nowhere.” “I saw her and thought, who is this chick? I gotta work with her. She’s bad.”

A lifelong fan of the jazz musician, Cheadle, himself an accomplished saxophone player and, now, a trumpet player, said he was introduced to Davis’ music at a young age as it was the music his parents listened to. “I’ve had his music in my life for a long time.” Indeed, when he left home the only album of his parents that he took with him — “unbeknownst to them” — was “Porgy and Bess,” Davis’ acclaimed collaboration with Gil Evans.

Nevertheless, Cheadle says he discovered a great deal in making the film. “My research of his music was exhaustive. And I’m still digging through all that stuff.”

The filmmaker managed to not only capture Davis’ music and spirit in the film, but also in how he managed to finance at least some of it. “Late in the game we still had a gap, we did not have full financing, so we went with Indiegogo to put together crowdsourcing.” Cheadle said the production raised around $370,000 in gap financing through the website. “It felt meta,” he added, pointing out that it was in line with Davis’ view of “social music — everybody could be part of that.”