I made a small program to test out the papi library.
In it I found 6 preset events which are available on my machine but are not able to be added together. So I figured this is perfect to test out multiplexing. I tried adding them with multiplexing enabled but it still gives the same error. See picture below:

Here's also my code;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "papi.h"
#include <stdbool.h>
#include "sys_basemacros.h"
extern int papi_custom();
int papi_custom() {
int scanf_warnings;
int s;
int i = 0;
int j = 0;
int eventset = PAPI_NULL;
int event_code = 0;
char str[20];
bool ok = false;
bool multiplex = false;
int retval;
PAPI_event_info_t info;
size_t size = 1024; // Assigning memory to measure performance during copying of data
// Moved these declarations above the memory allocation code.
char* src;
char* dst;
int* events;
long long(*count)[3];
// Now you can allocate memory after all declarations are done.
src = (char*)malloc(size);
dst = (char*)malloc(size);
if (src == NULL || dst == NULL) {
printf("Memory allocation failed!\n");
free(src);
free(dst);
return 0;
}
memset(src, 'A', size);
printf("\nInput the number of events: ");
scanf_warnings = scanf("%d", &s);
// Allocate memory for events and count arrays after knowing the size.
events = (int*)malloc(s * sizeof(int));
count = (long long(*)[3])malloc(s * 3 * sizeof(long long));
retval = PAPI_library_init(PAPI_VER_CURRENT); // Initializing PAPI
if (retval != PAPI_VER_CURRENT) {
fprintf(stderr, "Error initializing PAPI! %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
printf("Do you wish to enable multiplexing y/n: ");
while (!multiplex) {
scanf_warnings = scanf("%19s", str);
if (str[0] == 'y') {
multiplex = true;
retval = PAPI_multiplex_init();
if (retval != PAPI_OK) {
fprintf(stderr, "Error initializing multiplexing %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
}
else if (str[0] == 'n') {
multiplex = true;
}
else {
printf("Wrong input, try again y/n: ");
}
}
printf("\nInput the events you want to measure, press enter after each event: ");
while (i < s) {
while (!ok) {
scanf_warnings = scanf("%19s", str);
retval = PAPI_event_name_to_code(str, &event_code);
if (retval != PAPI_OK) {
printf("\nEvent unavailable, input again: ");
}
else {
retval = PAPI_get_event_info(event_code, &info);
if (retval != PAPI_OK) {
printf("\nEvent unavailable, input again: ");
}
else {
if (info.count > 0) {
ok = true;
events[i] = event_code;
}
else {
printf("\nEvent unavailable, input again: ");
}
}
}
}
i++;
ok = false;
}
i = 0;
retval = PAPI_create_eventset(&eventset); // Creating the eventset
if (retval != PAPI_OK) {
fprintf(stderr, "Error creating eventset! %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
retval = PAPI_add_events(eventset, events, s); // Adding the array of events to the set
if (retval != PAPI_OK) {
fprintf(stderr, "Error adding events %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
if (multiplex) { // Converts eventset to a multiplexing one
retval = PAPI_set_multiplex(eventset);
if (retval != PAPI_OK) {
fprintf(stderr, "Error converting eventset to a multiplexing eventset %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
}
while (i < 3) {
PAPI_reset(eventset);
retval = PAPI_start(eventset); // Starts the eventset measurement
if (retval != PAPI_OK) {
fprintf(stderr, "Error starting PAPI: %s\n", PAPI_strerror(retval));
free(src);
free(dst);
free(events);
free(count);
return 0;
}
memcpy(dst, src, size); // What's being measured
retval = PAPI_stop(eventset, count[i]);
if (retval != PAPI_OK) {
fprintf(stderr, "Error stopping: %s\n", PAPI_strerror(retval));
}
i++;
}
i = 0;
while (i < 3) {
j = 0; // Reset j for each iteration of i
while (j < s) {
PAPI_get_event_info(events[j], &info);
printf("\n%s: %lld", info.symbol, count[i][j]);
j++;
}
printf("\n");
i++;
}
if (scanf_warnings == 1) {
i++;
}
free(src);
free(dst);
free(events);
free(count);
printf("\n");
return 0;
}